<?php
namespace Api\Controller;
use Common\Controller\AppserviceController;
header('Content-type:text/html;charset=utf-8');
/**
 *计划任务
*/
class IndexController extends AppserviceController
{

    //获取 接口数据
    static function get_data($a)
    {
        $file_contents = file_get_contents("./public/json/{$a}.json");
        $data = json_decode($file_contents, true);
        $arr = $data["data"];
        foreach ($arr as $k => $v) {
            $arr[$k]['ocode'] = explode(",", $v['opencode']);
        }
        foreach ($arr as $k => $v) {
            $m = 0;
            foreach ($v['ocode'] as $kc => $vc) {
                $m += $vc;
            }
            $arr[$k]['total'] = $m;
            if ($m >= 3 && $m <= 10) {
                $arr[$k]['size'] = '1';//小
            }
            if ($m >= 11 && $m <= 18) {
                $arr[$k]['size'] = '2';//大
            }
            if ($m % 2 != 0) {
                $arr[$k]['attr'] = '1';//单
            } else {
                $arr[$k]['attr'] = '2';//双
            }
        }
        return $arr;
    }

    static function get_data2($a)
    {
        $file_contents = file_get_contents("./public/json/{$a}.json");
        $data = json_decode($file_contents, true);
        $arr = $data["data"];
        foreach ($arr as $k => $v) {
            $arr[$k]['otime'] = date("H:i:s", $v['opentimestamp']);
            $arr[$k]['ocode'] = explode(",", $v['opencode']);
        }
        return $arr;
    }

    //获取 北京k3 北京kl8 北京PK10 每天的第一期
    public function tesu()
    {
        //北京k3
        $stime = strtotime(date("Y-m-d") . " 00:00:00");

        $file_contents = file_get_contents("./public/json/bjk3.json");
        $data = json_decode($file_contents, true);
        $arr = $data["data"];
        foreach ($arr as $k => $v) {
            if ($v['opentimestamp'] < $stime) {
                $resu = $arr[$k];
                break;
            }
        }
        $ss = date("Y-m-d");
        $rs = M("day_start")->where("date = '{$ss}' and type = 1")->find();
        if (empty($rs)) {
            if (substr($resu['expect'], 0, 1) == '0') {
                $h = $resu['expect'] + 1;
                $start = '0' . $h;
            } else {
                $start = $resu['expect'] + 1;
            }
            $data = array(
                'type' => 1,
                'issue' => $start,
                'date' => date("Y-m-d")
            );
            M("day_start")->add($data);
        }
        //kl8

        $file_contents1 = file_get_contents("./public/json/bjkl8.json");
        $data1 = json_decode($file_contents1, true);
        $arr1 = $data1["data"];
        foreach ($arr1 as $k1 => $v1) {
            if ($v1['opentimestamp'] < $stime) {
                $resu1 = $arr1[$k1];
                break;
            }
        }
        $rs1 = M("day_start")->where("date = '{$ss}' and type = 2")->find();
        if (empty($rs1)) {
            $start1 = $resu1['expect'] + 1;
            $data1 = array(
                'type' => 2,
                'issue' => $start1,
                'date' => date("Y-m-d")
            );
            M("day_start")->add($data1);
        }
        //pk10
        $file_contents2 = file_get_contents("./public/json/bjpk10.json");
        $data2 = json_decode($file_contents2, true);
        $arr2 = $data2["data"];
        foreach ($arr2 as $k2 => $v2) {
            if ($v2['opentimestamp'] < $stime) {
                $resu2 = $arr2[$k1];
                break;
            }
        }
        $rs2 = M("day_start")->where("date = '{$ss}' and type = 3")->find();
        if (empty($rs2)) {
            $start2 = $resu2['expect'] + 1;
            $data2 = array(
                'type' => 3,
                'issue' => $start2,
                'date' => date("Y-m-d")
            );
            M("day_start")->add($data2);
        }
    }

    //每天00:00执行一次 每日加奖
    public function c_do()
    {
        $info = M("accountsinfo r")
            //   	->join("join ".C("DB_PREFIX")."accountsinfo a on t.uid = a.userid")
            ->join("join " . C("DB_PREFIX") . "up_level u on r.userid = u.uid")
            ->where("u.type = 2 and u.level>=3")
            ->field("r.userid,u.level,r.money")
            ->select();

        $ids = array();
        foreach ($info as $k => $v) {
            $ids[] = $v['userid'];
        }
        $cid = implode(",", $ids);
        //条件
        $where = array();
        $where['uid'] = array('in', $cid);
        $stime = date('Y-m-d', strtotime('-1 day')) . " 00:00:00";//昨天开始时间
        $etime = date('Y-m-d', strtotime('-1 day')) . " 23:59:59";//昨天结束时间
        $stimes = strtotime($stime);
        $etimes = strtotime($etime);
        $where['ctime'] = array(array('egt', $stimes), array('elt', $etimes));
        //查表
        $data1 = M('lottery_add')->where($where)->select();
        $data2 = M('lottery_11x5')->where($where)->select();
        $data3 = M('lottery_fc3d')->where($where)->select();
        $data4 = M('lottery_kl8')->where($where)->select();
        $data5 = M('lottery_pk10')->where($where)->select();
        $data6 = M('lottery_ssc')->where($where)->select();
        $data = array_merge($data1, $data2, $data3, $data4, $data5, $data6);
        $item = array();
        foreach ($data as $k => $v) {
            if (!isset($item[$v['uid']])) {
                $item[$v['uid']] = $v;
            } else {
                $item[$v['uid']]['money'] += $v['money'];
            }
        }
        foreach ($item as $ka => $va) {
            foreach ($info as $kk => $vv) {
                if ($va['uid'] == $vv['userid']) {
                    $item[$ka]['level'] = $vv['level'];
                    $item[$ka]['u_money'] = $vv['money'];
                }
            }
        }
        foreach ($item as $kc => $vc) {
            //可得嘉奖
            $jiajiang = 0;
            if ($vc['money'] >= '100') {
                if ($vc['level'] == '3') {
                    $jiajiang = $vc['money'] * 0.006;
                } elseif ($vc['level'] == '4') {
                    $jiajiang = $vc['money'] * 0.007;
                } elseif ($vc['level'] == '5') {
                    $jiajiang = $vc['money'] * 0.008;
                } elseif ($vc['level'] == '6') {
                    $jiajiang = $vc['money'] * 0.009;
                } elseif ($vc['level'] == '7') {
                    $jiajiang = $vc['money'] * 0.010;
                } elseif ($vc['level'] == '8') {
                    $jiajiang = $vc['money'] * 0.011;
                } elseif ($vc['level'] == '9') {
                    $jiajiang = $vc['money'] * 0.012;
                }
            }
            $upd[] = array("userid" => $kc, "money" => $jiajiang + $vc['u_money']);
            $history_date[] = array(
                'number' => date("Ymd") . rand(100000, 999999),
                'type' => '7',
                'shou_money' => $jiajiang,
                'ky_money' => $jiajiang + $vc['u_money'],
                'ctime' => time(),
                'uid' => $kc,
                'remark' => '活动礼金'
            );
        }
        M("jiaoyi")->addAll($history_date);
        $sq = "";
        foreach ($upd as $ki => $vi) {
            $sq .= " when userid = {$vi['userid']} then '{$vi['money']}' ";
        }
        $sql = "";
        if (!empty($sq)) {
            $sql .= ",money = CASE {$sq} else money end ";
        }
        if (!empty($sql)) {
            $sql = trim($sql, ',');
            $sql = "update " . C("DB_PREFIX") . "accountsinfo set {$sql}";
            M()->execute($sql);
        }
    }

    //清空 up_level 表中type=3 的数据 http://sfc.zai0312.com/Index.php/api/index/clear_level3  每天的 9：30：00
    public function clear_level3()
    {
        $ss['is_lingqu'] = 0;
        $ss['kl_money'] = 0;
        $ss['lq_time'] = 0;
        M('up_level')->where(" type=3")->save($ss);
    }

    //清空 up_level 表中type=4 的数据 http://sfc.zai0312.com/Index.php/api/index/clear_level4  每天的 8：30：00
    public function clear_level4()
    {
        $ss['is_lingqu'] = 0;
        $ss['kl_money'] = 0;
        $ss['lq_time'] = 0;
        M('up_level')->where(" type=4")->save($ss);
    }

    //清空 up_level 表中type=6 的数据 http://sfc.zai0312.com/Index.php/api/index/clear_level6  每年的 某天00:00:00
    public function clear_level6()
    {
        $info = M()
            ->table('QPAccountsDB.dbo.Accountsinfo r')
            ->join("ShiFen_Lottery.dbo.sp_up_level u on r.userid = u.uid")
            ->where("u.type = 2 and u.level>=3")
            ->field("r.userid,u.level,r.birth")
            ->select();
        $ids = array();
        foreach ($info as $k => $v) {
            $ids[] = $v['userid'];
            $birth[] = $v['birth'];
        }
        $arr = array();
        foreach ($birth as $v) {
            if (trim($v['birth'])) {
                $arr[] = date("m-d", strtotime($v . "00:00:00"));
            }
        }
        $time = date('m-d', time()); //当前时间的数组

        $cid = implode(",", $ids);
        //条件
        $where = array();
        //uid
        $where['uid'] = array('in', $cid);
        $where['type'] = 6;

        if (in_array($time, $arr)) {   //in_array 用法是 前边是一个字符串 后边是一数组
            $ss['is_lingqu'] = 0;
            $ss['kl_money'] = 0;
            $ss['lq_time'] = 0;
            M('up_level')->where($where)->save($ss);
        }

    }
    //多维数组判断值是否存在
    static function deep_in_array($value, $array)
    {
        foreach ($array as $item) {
            if (!is_array($item)) {
                $it = explode("-", $item);
                if ($it[0] == $value) {
                    return true;
                } else {
                    continue;
                }
            }
            if (in_array($value, $item)) {
                return true;
            } else if (self::deep_in_array($value, $item)) {
                return true;
            }
        }
        return false;
    }

    //追号11选5判断  1分钟1次
    public function zhui_11x5()
    {
        $house888 = M("zhui_x5_detail a")
            ->join(" join " . C("DB_PREFIX") . "zhui_x5 b on a.zhui_x5_id = b.id")
            ->field(array("a.*,b.lotteryclass,b.is_ting,b.z_type2,b.z_type,b.lv1,b.lv2_qi,b.lv2,b.lv3,b.moneys"))
            ->where("a.is_zhong = 0")
            ->select();
        $ren_gong = M("ren_gong")->where("1=1")->select();
        $jx11x5 = $this->get_data2("jx11x5");
        $sd11x5 = $this->get_data2("sd11x5");
        $sh11x5 = $this->get_data2("sh11x5");
        $gd11x5 = $this->get_data2("gd11x5");
        $myss = array();
        $wz = array();
        if (!empty($house888)) {
            foreach ($house888 as $k => $v) {
                $resu = array();
                $arr = array();
                $qu = array();
                $a = 0;
                $b = 0;
                $ne = array();
                $n = 0;
                if ($v['lotteryclass'] == '22') {
                    $arr = $gd11x5;
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 22, $v['issue']);
                    }
                } else if ($v['lotteryclass'] == '23') {
                    $arr = $sh11x5;
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 23, $v['issue']);
                    }
                } else if ($v['lotteryclass'] == '24') {
                    $arr = $sd11x5;
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 24, $v['issue']);
                    }
                } else if ($v['lotteryclass'] == '25') {
                    $arr = $jx11x5;
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 25, $v['issue']);
                    }
                }
                foreach ($arr as $ka => $va) {
                    if (array_search(trim($v['issue']), $va)) {
                        $resu = $arr[$ka];
                        break;
                    }
                }
                if (!empty($resu)) {
                    //三码
                    if ($v['type'] == '1') {
                        if ($v['m_type'] == '1') {
                            $arr1 = explode(",", rtrim($v['cal']));
                            $a1 = explode(",", str_replace(" ", ",", $arr1[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr1[1]));
                            $a3 = explode(",", str_replace(" ", ",", $arr1[2]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    foreach ($a3 as $k3 => $v3) {
                                        if ($v1 != $v2 && $v2 != $v3 && $v1 != $v3) {
                                            $qu[] = $v1 . ',' . $v2 . ',' . $v3;
                                        }
                                    }
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 8) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $arr1 = explode(",", str_replace(" ", "", rtrim($v['cal'])));
                            $c1 = str_replace(",", "", $resu['opencode']);
                            foreach ($arr1 as $kk => $vv) {
                                if ($c1 === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ne = getCombinationToString($ar, 3);
                            $nr = explode(",", $resu['opencode']);
                            sort($nr);
                            $qe = implode(",", $nr);
                            foreach ($ne as $kk => $vv) {
                                if ($qe === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar = explode(",", rtrim($v['cal']));
                            foreach ($ar as $kk => $vv) {
                                $ts = explode(" ", $vv);
                                sort($ts);
                                $ar[$kk] = str_replace(" ", "", implode(" ", $ts));
                            }
                            $nr = explode(",", $resu['opencode']);
                            sort($nr);
                            $qe = str_replace(",", "", implode(",", $nr));
                            foreach ($ar as $kk1 => $vv1) {
                                if ($qe === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        //前三组选胆拖
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", $v['cal']);
                            $pa = explode(",", str_replace(" ", ",", $ar1[0]));
                            if (count($pa) == '1') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 3);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    if (in_array($ar1[0], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '2') {
                                $cc = explode(",", rtrim($v['cal']));
                                $ty = str_replace(" ", ",", $cc[0]);
                                $rq = explode(",", str_replace(" ", ",", $cc[1]));
                                foreach ($rq as $k => $v) {
                                    $ne[] = $ty . ',' . $v;
                                }
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", substr($resu['opencode'], 0, 8));
                            sort($op);
                            $nstr = implode(",", $op);
                            if (in_array($nstr, $ne)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                    }
                    //二码
                    if ($v['type'] == '2') {
                        if ($v['m_type'] == '1') {
                            $arr1 = explode(",", rtrim($v['cal']));
                            $a1 = explode(",", str_replace(" ", ",", $arr1[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr1[1]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    if ($v1 != $v2) {
                                        $qu[] = $v1 . ',' . $v2;
                                    }
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 5) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $arr1 = explode(",", rtrim($v['cal']));
                            foreach ($arr1 as $kk => $vv) {
                                if (str_replace(" ", ",", $vv) === substr($resu['opencode'], 0, 5)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ne = getCombinationToString($ar, 2);
                            $nr = explode(",", $resu['opencode']);
                            sort($nr);
                            $qe = implode(",", $nr);
                            foreach ($ne as $kk => $vv) {
                                if (substr($qe, 0, 5) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar = explode(",", rtrim($v['cal']));
                            foreach ($ar as $kk => $vv) {
                                $ts = explode(" ", $vv);
                                sort($ts);
                                $ar[$kk] = str_replace(" ", "", implode(" ", $ts));
                            }
                            $nr = explode(",", $resu['opencode']);
                            sort($nr);
                            $qe = str_replace(",", "", implode(",", $nr));
                            foreach ($ar as $kk1 => $vv1) {
                                if (substr($qe, 0, 4) === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        //前二组选胆拖
                        if ($v['m_type'] == '5') {
                            $cc = explode(",", rtrim($v['cal']));
                            $ty = str_replace(" ", ",", $cc[0]);
                            $rq = explode(",", str_replace(" ", ",", $cc[1]));
                            foreach ($rq as $k => $v) {
                                $ne[] = $ty . ',' . $v;
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", substr($resu['opencode'], 0, 5));
                            sort($op);
                            $nstr = implode(",", $op);
                            if (in_array($nstr, $ne)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                    }
                    //不定位
                    if ($v['type'] == '3') {
                        if ($v['m_type'] == '1') {
                            $ar = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            if (in_array(substr($resu['opencode'], 0, 2), $ar)) {
                                $zid[] = $v['id'];
                            }
                            if (in_array(substr($resu['opencode'], 3, 2), $ar)) {
                                $zid[] = $v['id'];
                            }
                            if (in_array(substr($resu['opencode'], 6, 2), $ar)) {
                                $zid[] = $v['id'];
                            }
                            $zid = array_unique($zid);
                        }
                    }
                    //定位胆
                    if ($v['type'] == '4') {
                        if ($v['m_type'] == '1') {
                            $aa = rtrim($v['cal']);
                            $ar1 = explode(",", $aa);
                            $ar2 = explode(",", substr($resu['opencode'], 0, 8));
                            for ($i = 0; $i < 3; $i++) {
                                if ($ar1[$i] === $ar2[$i]) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //趣味性
                    if ($v['type'] == '5') {
                        if ($v['m_type'] == '1') {
                            $qd = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = explode(",", $resu['opencode']);
                            foreach ($ar2 as $ka => $va) {
                                if ($va % 2 == 0) {
                                    $a++;
                                } else {
                                    $b++;
                                }
                            }
                            $str = $b . "单" . $a . "双";
                            if (in_array($str, $qd)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $qd = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = explode(",", $resu['opencode']);
                            sort($ar2);
                            if (in_array($ar2['2'], $qd)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                    }
                    //任选复式
                    if ($v['type'] == '6') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $ka => $va) {
                                if (in_array($va, $op)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nas = getCombinationToString($ar1, 2);
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($nas as $kk => $vv) {
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nas = getCombinationToString($ar1, 3);
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($nas as $kk => $vv) {
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        if (in_array($ab[2], $op)) {
                                            //中奖
                                            $zid[] = $v['id'];
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nas = getCombinationToString($ar1, 4);
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($nas as $kk => $vv) {
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        if (in_array($ab[2], $op)) {
                                            if (in_array($ab[3], $op)) {
                                                //中奖
                                                $zid[] = $v['id'];
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nas = getCombinationToString($ar1, 5);
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($nas as $kk => $vv) {
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        if (in_array($ab[2], $op)) {
                                            if (in_array($ab[3], $op)) {
                                                if (in_array($ab[4], $op)) {
                                                    //中奖
                                                    $zid[] = $v['id'];
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nas = getCombinationToString($ar1, 6);
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($nas as $kk => $vv) {
                                $n = 0;
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $n++;
                                }
                                if ($n >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nas = getCombinationToString($ar1, 7);
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($nas as $kk => $vv) {
                                $n = 0;
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[6], $op)) {
                                    $n++;
                                }
                                if ($n >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nas = getCombinationToString($ar1, 8);
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($nas as $kk => $vv) {
                                $n = 0;
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[6], $op)) {
                                    $n++;
                                }
                                if (in_array($ab[7], $op)) {
                                    $n++;
                                }
                                if ($n >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //任选单式
                    if ($v['type'] == '7') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                if (in_array($vv, $op)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                $ab = explode(",", str_replace(" ", ",", $vv));
                                sort($ab);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                $ab = explode(",", str_replace(" ", ",", $vv));
                                sort($ab);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        if (in_array($ab[2], $op)) {
                                            //中奖
                                            $zid[] = $v['id'];
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                $ab = explode(",", str_replace(" ", ",", $vv));
                                sort($ab);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        if (in_array($ab[2], $op)) {
                                            if (in_array($ab[3], $op)) {
                                                //中奖
                                                $zid[] = $v['id'];
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                $ab = explode(",", str_replace(" ", ",", $vv));
                                sort($ab);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        if (in_array($ab[2], $op)) {
                                            if (in_array($ab[3], $op)) {
                                                if (in_array($ab[4], $op)) {
                                                    //中奖
                                                    $zid[] = $v['id'];
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                $u = 0;
                                $ab = explode(",", str_replace(" ", ",", $vv));
                                sort($ab);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if ($u >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                $u = 0;
                                $ab = explode(",", str_replace(" ", ",", $vv));
                                sort($ab);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[6], $op)) {
                                    $u++;
                                }
                                if ($u >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                $u = 0;
                                $ab = explode(",", str_replace(" ", ",", $vv));
                                sort($ab);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[6], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[7], $op)) {
                                    $u++;
                                }
                                if ($u >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //任选胆拖
                    if ($v['type'] == '8') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            $na = explode(",", str_replace(" ", ",", $ar1[1]));
                            $cp = array();
                            foreach ($na as $ka => $va) {
                                $cp[] = $ar1[0] . "," . $va;
                            }
                            foreach ($cp as $kk => $vv) {
                                $rt = explode(",", $vv);
                                sort($rt);
                                $cp[$kk] = implode(",", $rt);
                            }
                            sort($op);
                            foreach ($cp as $kq => $vq) {
                                $u = 0;
                                $ab = explode(",", $vq);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", $v['cal']);
                            $pa = explode(",", str_replace(" ", ",", $ar1[0]));
                            if (count($pa) == '1') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 3);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    if (in_array($ar1[0], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '2') {
                                $cc = explode(",", rtrim($v['cal']));
                                $ty = str_replace(" ", ",", $cc[0]);
                                $rq = explode(",", str_replace(" ", ",", $cc[1]));
                                foreach ($rq as $k => $v) {
                                    $ne[] = $ty . ',' . $v;
                                }
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", substr($resu['opencode'], 0, 8));
                            sort($op);
                            $nstr = implode(",", $op);
                            if (in_array($nstr, $ne)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", $v['cal']);
                            $pa = explode(",", str_replace(" ", ",", $ar1[0]));
                            if (count($pa) == '1') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 4);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    if (in_array($ar1[0], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '2') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 4);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else {
                                $cc = explode(",", rtrim($v['cal']));
                                $ty = str_replace(" ", ",", $cc[0]);
                                $rq = explode(",", str_replace(" ", ",", $cc[1]));
                                foreach ($rq as $k => $v) {
                                    $ne[] = $ty . ',' . $v;
                                }
                                foreach ($ne as $k1 => $v1) {
                                    $ts = explode(",", $v1);
                                    sort($ts);
                                    $ne[$k1] = implode(",", $ts);
                                }
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            $nstr = implode(",", $op);
                            $ss = substr($nstr, 0, 11);
                            if (in_array($ss, $ne)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", $v['cal']);
                            $pa = explode(",", str_replace(" ", ",", $ar1[0]));
                            if (count($pa) == '1') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 5);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    if (in_array($ar1[0], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '2') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 5);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '3') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 5);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else {
                                $cc = explode(",", rtrim($v['cal']));
                                $ty = str_replace(" ", ",", $cc[0]);
                                $rq = explode(",", str_replace(" ", ",", $cc[1]));
                                foreach ($rq as $k => $v) {
                                    $ne[] = $ty . ',' . $v;
                                }
                                foreach ($ne as $k1 => $v1) {
                                    $ts = explode(",", $v1);
                                    sort($ts);
                                    $ne[$k1] = implode(",", $ts);
                                }
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            $nstr = implode(",", $op);
                            if (in_array($nstr, $ne)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", $v['cal']);
                            $pa = explode(",", str_replace(" ", ",", $ar1[0]));
                            if (count($pa) == '1') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 6);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    if (in_array($ar1[0], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '2') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 6);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '3') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 6);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '4') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 6);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr) && in_array($ae[3], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else {
                                $cc = explode(",", rtrim($v['cal']));
                                $ty = str_replace(" ", ",", $cc[0]);
                                $rq = explode(",", str_replace(" ", ",", $cc[1]));
                                foreach ($rq as $k => $v) {
                                    $ne[] = $ty . ',' . $v;
                                }
                                foreach ($ne as $k1 => $v1) {
                                    $ts = explode(",", $v1);
                                    sort($ts);
                                    $ne[$k1] = implode(",", $ts);
                                }
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            $nstr = implode(",", $op);
                            foreach ($ne as $kk => $vv) {
                                $u = 0;
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if ($u >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", $v['cal']);
                            $pa = explode(",", str_replace(" ", ",", $ar1[0]));
                            if (count($pa) == '1') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 7);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    if (in_array($ar1[0], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '2') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 7);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '3') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 7);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '4') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 7);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr) && in_array($ae[3], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '5') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 7);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr) && in_array($ae[3], $qr) && in_array($ae[4], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else {
                                $cc = explode(",", rtrim($v['cal']));
                                $ty = str_replace(" ", ",", $cc[0]);
                                $rq = explode(",", str_replace(" ", ",", $cc[1]));
                                foreach ($rq as $k => $v) {
                                    $ne[] = $ty . ',' . $v;
                                }
                                foreach ($ne as $k1 => $v1) {
                                    $ts = explode(",", $v1);
                                    sort($ts);
                                    $ne[$k1] = implode(",", $ts);
                                }
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            $nstr = implode(",", $op);
                            foreach ($ne as $kk => $vv) {
                                $u = 0;
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[6], $op)) {
                                    $u++;
                                }
                                if ($u >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", $v['cal']);
                            $pa = explode(",", str_replace(" ", ",", $ar1[0]));
                            if (count($pa) == '1') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 8);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    if (in_array($ar1[0], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '2') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 8);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '3') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 8);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '4') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 8);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr) && in_array($ae[3], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '5') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 8);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr) && in_array($ae[3], $qr) && in_array($ae[4], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '6') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 8);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr) && in_array($ae[3], $qr) && in_array($ae[4], $qr) && in_array($ae[5], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else {
                                $cc = explode(",", rtrim($v['cal']));
                                $ty = str_replace(" ", ",", $cc[0]);
                                $rq = explode(",", str_replace(" ", ",", $cc[1]));
                                foreach ($rq as $k => $v) {
                                    $ne[] = $ty . ',' . $v;
                                }
                                foreach ($ne as $k1 => $v1) {
                                    $ts = explode(",", $v1);
                                    sort($ts);
                                    $ne[$k1] = implode(",", $ts);
                                }
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            $nstr = implode(",", $op);
                            foreach ($ne as $kk => $vv) {
                                $u = 0;
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[6], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[7], $op)) {
                                    $u++;
                                }
                                if ($u >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    $jieg[] = array($v['id'] => $resu['opencode']);
                }
            }
            $temp = array();
            foreach ($jieg as $kg => $vg) {
                foreach ($vg as $kt => $vt) {
                    if (!in_array($kt, $temp)) {
                        $temp[$kt] = $vt;
                    }
                }
            }
            $sq = "";
            foreach ($temp as $ki => $vi) {
                $sq .= " when id = {$ki} then '{$vi}' ";
            }
            $sql = "";
            if (!empty($sq)) {
                $sql .= ",opencode = CASE {$sq} else opencode end ";
            }
            if (!empty($sql)) {
                $sql = trim($sql, ',');
                $sql = "update " . C("DB_PREFIX") . "zhui_x5_detail set {$sql}";
                M()->execute($sql);
            }
            foreach ($house888 as $k1 => $v1) {
                foreach ($arr as $ka => $va) {
                    if (array_search(trim($v1['issue']), $va)) {
                        if (!in_array($v1['id'], $zid)) {
                            $wz[] = $v1['id'];
                        }
                        break;
                    }
                }
            }
            if (!empty($wz)) {
                $ccd = implode(",", $wz);
                M("zhui_x5_detail")->where("id in($ccd)")->save(array("is_zhong" => 2));
            }
            if (!empty($zid)) {
                $zd = implode(",", $zid);
                M("zhui_x5_detail")->where("id in($zd)")->save(array("is_zhong" => 1));
                $res = M("zhui_x5_detail d")
                    ->join(" join " . C("DB_PREFIX") . "zhui_x5 s on d.zhui_x5_id=s.id")
                    ->where("d.id in($zd)")
                    ->field("d.id,d.zhui_x5_id,d.zhong_money,s.uid,s.is_ting,s.z_type2,s.z_type,s.lv1,s.lv2_qi,s.lv2,s.lv3,s.moneys,d.touzhu_money,d.is_zhong")
                    ->select();
                foreach ($res as $kz => $vz) {
                    $uu[] = $vz['uid'];
                }
                $uz = implode(",", $uu);
                $moz = array();
                if ($uz) {
                    $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                    $moz = $mo;
                }
                foreach ($res as $kp1 => $vp1) {
                    foreach ($mo as $kp2 => $vp2) {
                        if ($vp1['uid'] == $vp2['userid']) {
                            $res[$kp1]['money'] = $vp2['money'];
                        }
                    }
                }
                foreach ($res as $kb => $vb) {
                    if ($vb['is_ting'] == '1') {
                        $p1[] = $vb['id'];
                    }
                    if ($vb['is_ting'] == '2') {
                        $p2[] = $vb['id'];
                    }
                    if ($vb['z_type2'] == '1' || $vb['z_type2'] == '2') {
                        $p3[] = $vb['id'];
                    }
                }
                $zhui_x5_detail3 = array();
                $jiaoyi_date = array();
                if ($p1) {
//					$zd = implode(",",$p1);
                    $res1 = array();
                    foreach ($res as $v1) {
                        if (in_array($v['id'], $p1)) {
                            $res1[] = array(
                                'zhui_x5_id' => $v1['zhui_x5_id'],
                                'zhong_money' => $v1['zhong_money'],
                                'uid' => $v1['uid'],
                            );
                        }
                    }
                    foreach ($res1 as $kz => $vz) {
                        $uu[] = $vz['uid'];
                    }
                    $uz = implode(",", $uu);
                    if ($uz) {
                        $mo = array();
                        foreach ($moz as $v) {
                            if (in_array($v['userid'], $uu)) {
                                $mo[] = $v;
                            }
                        }
                    }
                    foreach ($res1 as $kp1 => $vp1) {
                        foreach ($mo as $kp2 => $vp2) {
                            if ($vp1['uid'] == $vp2['userid']) {
                                $res1[$kp1]['money'] = $vp2['money'];
                            }
                        }
                    }
                    foreach ($res1 as $kp => $vp) {
                        $zz[] = $vp['zhui_x5_id'];
                        $uudd[] = $vp['uid'];
                        $history_date[] = array(
                            'number' => date("Ymd") . rand(100000, 999999),
                            'type' => '5',
                            'shou_money' => $vp['zhong_money'],
                            'ky_money' => $vp['money'],
                            'ctime' => time(),
                            'uid' => $vp['uid'],
                            'remark' => '奖金派送'
                        );
                    }
                    $lad = implode(",", $zz);
                    $udd = implode(",", $uudd);
                    $result = array();
                    foreach ($res1 as $ke1 => $info) {
                        if ($result[$info['zhui_x5_id']]) {
                            $result[$info['zhui_x5_id']] += $info['zhong_money'];
                        } else {
                            $result[$info['zhui_x5_id']] = trim($info['zhong_money']);
                        }
                    }
                    $result1 = array();
                    foreach ($res1 as $ke2 => $info2) {
                        if ($result1[$info2['uid']]) {
                            $result1[$info2['uid']] += $info2['zhong_money'];
                        } else {
                            $result1[$info2['uid']] = trim($info2['zhong_money']);
                        }
                    }
                    foreach ($result1 as $kwi => $vwi) {
                        foreach ($mo as $k11 => $v11) {
                            if ($kwi == $v11['userid']) {
                                $result1[$kwi] = $vwi + $v11['money'];
                            }
                        }
                    }
                    $sq = "";
                    $sq1 = "";
                    foreach ($result as $ki => $vi) {
                        $sq .= " when id = {$ki} then '{$vi}' ";
                    }
                    foreach ($result1 as $ki1 => $vi1) {
                        $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                    }
                    $sql = "";
                    if (!empty($sq)) {
                        $sql .= ",zo_money = CASE {$sq} else zo_money end ";
                    }
                    $sql1 = "";
                    if (!empty($sq1)) {
                        $sql1 .= ",money = CASE {$sq1} else money end ";
                    }
                    if (!empty($sql)) {
                        $sql = trim($sql, ',');
                        $sql = "update " . C("DB_PREFIX") . "zhui_x5 set {$sql}";
                        M()->execute($sql);
                    }
                    if (!empty($sql1)) {
                        $sql1 = trim($sql1, ',');
                        $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                        M()->execute($sql1);
                    }
                    $jiaoyi_date = empty($history_date) ? $jiaoyi_date : array_merge($jiaoyi_date, $history_date);
                    //停止追号
                    $ttt = array();
                    $lad_arr = empty($lad) ? array() : explode(",", $lad);
                    foreach ($res as $v) {
                        if (in_array($v['zhui_x5_id'], $lad_arr) && $v['is_zhong'] == 0) {
                            $ttt[] = array(
                                'uid' => $v['uid'],
                                'touzhu_money' => $v['touzhu_money'],
                                'id' => $v['id'],
                            );
                        }
                    }
                    $result3 = array();
                    $isr = array();
                    $tyu = array();
                    foreach ($ttt as $ke3 => $info3) {
                        $isr[] = $info3['id'];
                        $tyu[] = $info3['uid'];
                        if ($result3[$info3['uid']]) {
                            $result3[$info3['uid']] += $info3['touzhu_money'];
                        } else {
                            $result3[$info3['uid']] = trim($info3['touzhu_money']);
                        }
                    }
                    $dfg = implode(",", $tyu);
                    if ($dfg) {
                        $yy1 = array();
                        foreach ($moz as $v) {
                            if (in_array($v['userid'], $tyu)) {
                                $yy1[] = $v;
                            }
                        }
                    }

                    foreach ($yy1 as $kp1 => $vp1) {
                        $tui = array($vp1['userid'] => $vp1['money'] + $result3[$vp1['userid']]);
                        $history_date2[] = array(
                            'number' => date("Ymd") . rand(100000, 999999),
                            'type' => '8',
                            'shou_money' => $result3[$vp1['userid']],
                            'ky_money' => $vp1['money'],
                            'ctime' => time(),
                            'uid' => $vp1['userid'],
                            'remark' => '追号停止'
                        );
                    }
                    $jiaoyi_date = empty($history_date2) ? $jiaoyi_date : array_merge($jiaoyi_date, $history_date2);
                    $zhui_x5_detail3 = empty($isr) ? $zhui_x5_detail3 : array_merge($zhui_x5_detail3, $isr);
                    $sq2 = "";
                    foreach ($tui as $ki2 => $vi2) {
                        $sq2 .= " when userid = {$ki2} then '{$vi2}' ";
                    }
                    $sql2 = "";
                    if (!empty($sq2)) {
                        $sql2 .= ",money = CASE {$sq2} else money end ";
                    }
                    if (!empty($sql2)) {
                        $sql2 = trim($sql2, ',');
                        $sql2 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql2}";
                        M()->execute($sql2);
                    }

                }
                if ($p2) {
                    $res1 = array();
                    foreach ($res as $v) {
                        if (in_array($v['id'], $p2)) {
                            $res1[] = array(
                                'zhui_x5_id' => $v['zhui_x5_id'],
                                'zhong_money' => $v['zhong_money'],
                                'uid' => $v['uid'],
                            );
                        }
                    }
                    foreach ($res1 as $kz => $vz) {
                        $uu[] = $vz['uid'];
                    }
                    $uz = implode(",", $uu);
                    if ($uz) {
                        $mo = array();
                        foreach ($moz as $v) {
                            if (in_array($v['userid'], $uu)) {
                                $mo[] = $v;
                            }
                        }
                    }
                    foreach ($res1 as $kp1 => $vp1) {
                        foreach ($mo as $kp2 => $vp2) {
                            if ($vp1['uid'] == $vp2['userid']) {
                                $res1[$kp1]['money'] = $vp2['money'];
                            }
                        }
                    }
                    foreach ($res1 as $kp => $vp) {
                        $zz[] = $vp['zhui_x5_id'];
                        $uudd[] = $vp['uid'];
                        $history_date3[] = array(
                            'number' => date("Ymd") . rand(100000, 999999),
                            'type' => '5',
                            'shou_money' => $vp['zhong_money'],
                            'ky_money' => $vp['money'],
                            'ctime' => time(),
                            'uid' => $vp['uid'],
                            'remark' => '奖金派送'
                        );
                    }
                    $lad = implode(",", $zz);
                    $udd = implode(",", $uudd);
                    $result = array();
                    foreach ($res1 as $ke1 => $info) {
                        if ($result[$info['zhui_x5_id']]) {
                            $result[$info['zhui_x5_id']] += $info['zhong_money'];
                        } else {
                            $result[$info['zhui_x5_id']] = trim($info['zhong_money']);
                        }
                    }
                    $result1 = array();
                    foreach ($res1 as $ke2 => $info2) {
                        if ($result1[$info2['uid']]) {
                            $result1[$info2['uid']] += $info2['zhong_money'];
                        } else {
                            $result1[$info2['uid']] = trim($info2['zhong_money']);
                        }
                    }
                    foreach ($result1 as $kwi => $vwi) {
                        foreach ($mo as $k11 => $v11) {
                            if ($kwi == $v11['userid']) {
                                $result1[$kwi] = $vwi + $v11['money'];
                            }
                        }
                    }
                    $sq = "";
                    $sq1 = "";
                    foreach ($result as $ki => $vi) {
                        $sq .= " when id = {$ki} then '{$vi}' ";
                    }
                    foreach ($result1 as $ki1 => $vi1) {
                        $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                    }
                    $sql = "";
                    if (!empty($sq)) {
                        $sql .= ",zo_money = CASE {$sq} else zo_money end ";
                    }
                    $sql1 = "";
                    if (!empty($sq1)) {
                        $sql1 .= ",money = CASE {$sq1} else money end ";
                    }
                    if (!empty($sql)) {
                        $sql = trim($sql, ',');
                        $sql = "update " . C("DB_PREFIX") . "zhui_x5 set {$sql}";
                        M()->execute($sql);
                    }
                    if (!empty($sql1)) {
                        $sql1 = trim($sql1, ',');
                        $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                        M()->execute($sql1);
                    }
                    $jiaoyi_date = empty($history_date3) ? $jiaoyi_date : array_merge($jiaoyi_date, $history_date3);
                }
                if ($p3) {
                    $hh = 0;
                    $hh1 = 0;
                    $hh2 = 0;
                    $zd = implode(",", $p3);
                    $res1 = array();
                    foreach ($res as $v) {
                        if (in_array($v['id'], $p3)) {
                            $res1[] = array(
                                'zhui_x5_id' => $v['zhui_x5_id'],
                                'zhong_money' => $v['zhong_money'],
                                'uid' => $v['uid'],
                                'z_type' => $v['z_type'],
                                'moneys' => $v['moneys'],
                                'lv1' => $v['lv1'],
                                'lv2' => $v['lv2'],
                                'lv3' => $v['lv3'],
                                'lv2_qi' => $v['lv2_qi'],
                            );
                        }
                    }
                    foreach ($res1 as $kz => $vz) {
                        $uu[] = $vz['uid'];
                    }
                    $uz = implode(",", $uu);
                    if ($uz) {
                        $mo = array();
                        foreach ($moz as $v) {
                            if (in_array($v['userid'], $uu)) {
                                $mo[] = $v;
                            }
                        }
                    }
                    foreach ($res1 as $kp1 => $vp1) {
                        foreach ($mo as $kp2 => $vp2) {
                            if ($vp1['uid'] == $vp2['userid']) {
                                $res1[$kp1]['money'] = $vp2['money'];
                            }
                        }
                    }
                    foreach ($res1 as $kp => $vp) {
                        $zz[] = $vp['zhui_x5_id'];
                        $uudd[] = $vp['uid'];
                        $history_date5[] = array(
                            'number' => date("Ymd") . rand(100000, 999999),
                            'type' => '5',
                            'shou_money' => $vp['zhong_money'],
                            'ky_money' => $vp['money'],
                            'ctime' => time(),
                            'uid' => $vp['uid'],
                            'remark' => '奖金派送'
                        );
                    }
                    $lad = implode(",", $zz);
                    $udd = implode(",", $uudd);
                    $result = array();
                    foreach ($res1 as $ke1 => $info) {
                        if ($result[$info['zhui_x5_id']]) {
                            $result[$info['zhui_x5_id']] += $info['zhong_money'];
                        } else {
                            $result[$info['zhui_x5_id']] = trim($info['zhong_money']);
                        }
                    }
                    $result1 = array();
                    foreach ($res1 as $ke2 => $info2) {
                        if ($result1[$info2['uid']]) {
                            $result1[$info2['uid']] += $info2['zhong_money'];
                        } else {
                            $result1[$info2['uid']] = trim($info2['zhong_money']);
                        }
                    }
                    foreach ($result1 as $kwi => $vwi) {
                        foreach ($mo as $k11 => $v11) {
                            if ($kwi == $v11['userid']) {
                                $result1[$kwi] = $vwi + $v11['money'];
                            }
                        }
                    }
                    $sq = "";
                    $sq1 = "";
                    foreach ($result as $ki => $vi) {
                        $sq .= " when id = {$ki} then '{$vi}' ";
                    }
                    foreach ($result1 as $ki1 => $vi1) {
                        $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                    }
                    $sql = "";
                    if (!empty($sq)) {
                        $sql .= ",zo_money = CASE {$sq} else zo_money end ";
                    }
                    $sql1 = "";
                    if (!empty($sq1)) {
                        $sql1 .= ",money = CASE {$sq1} else money end ";
                    }
                    if (!empty($sql)) {
                        $sql = trim($sql, ',');
                        $sql = "update " . C("DB_PREFIX") . "zhui_x5 set {$sql}";
                        M()->execute($sql);
                    }
                    if (!empty($sql1)) {
                        $sql1 = trim($sql1, ',');
                        $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                        M()->execute($sql1);
                    }
                    $jiaoyi_date = empty($history_date5) ? $jiaoyi_date : array_merge($jiaoyi_date, $history_date5);
                    foreach ($res1 as $k2 => $v2) {
                        if ($v2['z_type'] == '1') {
                            $biaoz = ($v2['moneys'] * $v2['lv1']) / 100;
                            $myss[] = array(
                                'sid' => $v2['zhui_x5_id'],
                                'moy' => $v2['zhong_money']
                            );
                            foreach ($myss as $kp => $vp) {
                                if ($vp['sid'] == $v2['zhui_x5_id']) {
                                    $hh += $vp['moy'];
                                }
                            }
                            if ($hh >= $biaoz) {
                                //停止追号
                                $tz[] = $v['zhui_x5_id'];
                                break;
                            }
                        }
                        if ($v2['z_type'] == '2') {
                            $biaoz1 = ($v2['moneys'] * $v2['lv2']) / 100;
                            $biaoz2 = ($v2['moneys'] * $v2['lv3']) / 100;
                            $myss[] = array(
                                'sid' => $v2['zhui_x5_id'],
                                'moy' => $v2['zhong_money']
                            );
                            $posi = 1;
                            foreach ($myss as $kp => $vp) {
                                if ($posi < $v2['lv2_qi']) {
                                    if ($vp['sid'] == $v2['zhui_x5_id']) {
                                        $hh1 += $vp['moy'];
                                    }
                                    $posi++;
                                } else {
                                    if ($vp['sid'] == $v2['zhui_x5_id']) {
                                        $hh2 += $vp['moy'];
                                    }
                                }
                            }
                            if ($hh1 >= $biaoz1) {
                                //停止追号
                                $tz[] = $v['zhui_x5_id'];
                                break;
                            } else {
                                if ($hh2 >= $biaoz2) {
                                    //停止追号
                                    $tz[] = $v['zhui_x5_id'];
                                    break;
                                }
                            }
                        }
                    }
                    $tzz = implode(",", $tz);
                    if ($tzz) {
                        $ttt = array();
                        $lad_arr = empty($lad) ? array() : explode(",", $lad);
                        foreach ($res as $v) {
                            if (in_array($v['id'], $lad_arr) && $v['is_zhong'] == 0) {
                                $ttt[] = array(
                                    'id' => $v['id'],
                                    'touzhu_money' => $v['touzhu_money'],
                                    'uid' => $v['uid'],
                                );
                            }
                        }
                        $result3 = array();
                        $isr = array();
                        $tyu = array();
                        foreach ($ttt as $ke3 => $info3) {
                            $isr[] = $info3['id'];
                            $tyu[] = $info3['uid'];
                            if ($result3[$info3['uid']]) {
                                $result3[$info3['uid']] += $info3['touzhu_money'];
                            } else {
                                $result3[$info3['uid']] = trim($info3['touzhu_money']);
                            }
                        }
                        $irs = implode(",", $isr);
                        $dfg = implode(",", $tyu);
                        if ($dfg) {
                            $yy1 = array();
                            foreach ($moz as $v) {
                                if (in_array($v['userid'], $tyu)) {
                                    $yy1[] = $v;
                                }
                            }
                        }

                        foreach ($yy1 as $kp1 => $vp1) {
                            $tui = array($vp1['userid'] => $vp1['money'] + $result3[$vp1['userid']]);
                            $history_date22[] = array(
                                'number' => date("Ymd") . rand(100000, 999999),
                                'type' => '8',
                                'shou_money' => $result3[$vp1['userid']],
                                'ky_money' => $vp1['money'],
                                'ctime' => time(),
                                'uid' => $vp1['userid'],
                                'remark' => '追号停止'
                            );
                        }
                        $jiaoyi_date = empty($history_date22) ? $jiaoyi_date : array_merge($jiaoyi_date, $history_date22);
                        $zhui_x5_detail3 = empty($isr) ? $zhui_x5_detail3 : array_merge($zhui_x5_detail3, $isr);
                        $sq2 = "";
                        foreach ($tui as $ki2 => $vi2) {
                            $sq2 .= " when userid = {$ki2} then '{$vi2}' ";
                        }
                        $sql2 = "";
                        if (!empty($sq2)) {
                            $sql2 .= ",money = CASE {$sq2} else money end ";
                        }
                        if (!empty($sql2)) {
                            $sql2 = trim($sql2, ',');
                            $sql2 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql2}";
                            M()->execute($sql2);
                        }
                    }
                }
                if (!empty($jiaoyi_date)) {
                    M("jiaoyi")->addAll($jiaoyi_date);
                }
                if (!empty($zhui_x5_detail3)) {
                    $irs = implode(",", $zhui_x5_detail3);
                    M("zhui_x5_detail")->where("id in($irs) and is_zhong=0 ")->save(array("is_zhong" => 3, 'opencode' => "追号停止"));
                }
            }
        }
    }

    //追号时时彩判断  1分钟1次
    public function zhui_ssc1_bak()
    {
        //---------------追号时时彩---------------------
        $wz = array();
        $house999 = M("zhui_ssc_detail a")
            ->join(" join " . C("DB_PREFIX") . "zhui_ssc b on a.zhui_ssc_id = b.id")
            ->field(array("a.*,b.lotteryclass,b.is_ting,b.z_type2,b.z_type,b.lv1,b.lv2_qi,b.lv2,b.lv3,b.moneys"))
            ->where("a.is_zhong = 0")
            ->select();
        $mys = array();
        $ren_gong = M("ren_gong")->where("1=1")->select();
        if (!empty($house999)) {
            foreach ($house999 as $k => $v) {
                $resu = array();
                $arr = array();
                $qu = array();
                $a = 0;
                $b = 0;
                $ne = array();
                $n = 0;
                $str = array();
                $s = array();
                $s1 = array();
                if ($v['lotteryclass'] == '15') {
                    $arrsc = $this->get_data2("cqssc");
                    if (empty($arrsc)) {
                        $arr = $this->ren_gong($ren_gong, 15, $v['issue']);
                    }
                }
                if ($v['lotteryclass'] == '17') {
                    $arrsc = $this->get_data("xjssc");
                    if (empty($arrsc)) {
                        $arr = $this->ren_gong($ren_gong, 17, $v['issue']);
                    }
                }
                if ($v['lotteryclass'] == '18') {
                    $arrsc = $this->get_data2("tjssc");
                    if (empty($arrsc)) {
                        $arr = $this->ren_gong($ren_gong, 18, $v['issue']);
                    }
                }
                if ($v['lotteryclass'] == '19') {
                    $arrsc = $this->get_data("ffc2");
                    if (empty($arrsc)) {
                        $arr = $this->ren_gong($ren_gong, 19, $v['issue']);
                    }
                }
                foreach ($arrsc as $ka => $va) {
                    if (array_search(trim($v['issue']), $va)) {
                        $resu = $arrsc[$ka];
                        break;
                    }
                }
                if (!empty($resu)) {
                    //五星
                    if ($v['type'] == '1') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $pa1 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $pa2 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $pa3 = explode(",", str_replace(" ", ",", $ar1[2]));
                            $pa4 = explode(",", str_replace(" ", ",", $ar1[3]));
                            $pa5 = explode(",", str_replace(" ", ",", $ar1[4]));
                            $narr = array();
                            foreach ($pa1 as $ka => $va) {
                                foreach ($pa2 as $kb => $vb) {
                                    foreach ($pa3 as $kc => $vc) {
                                        foreach ($pa4 as $kq => $vq) {
                                            foreach ($pa5 as $kt => $vt) {
                                                if ($va && $vb && $vc && $vq && $vt) {
                                                    $narr[] = $va . ',' . $vb . ',' . $vc . ',' . $vq . ',' . $vt;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            foreach ($narr as $ki => $vi) {
                                $ts = explode(",", $vi);
                                $narr[$ki] = implode(",", $ts);
                            }
                            $op = explode(",", $resu['opencode']);
                            $nstr = implode(",", $op);
                            if (in_array($nstr, $narr)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ns = str_replace(",", "", $resu['opencode']);
                            if (in_array($ns, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 5);
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($ar2 as $ky => $vy) {
                                if ($tt === $vy) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ar2 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $ar3 = str_replace(" ", ",", $ar1[1]);
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $tt = implode(",", $nt);
                            $y = array();
                            foreach ($ar2 as $ky => $vy) {
                                $y[] = $vy . ',' . $vy . ',' . $ar3;
                            }
                            foreach ($y as $kk => $vv) {
                                $ts = explode(",", $vv);
                                sort($ts);
                                $y[$kk] = implode(",", $ts);
                            }
                            foreach ($y as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ar2 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $ar5 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $yu = array();
                            $ttt = array();
                            $ar3 = getCombinationToString($ar2, 2);
                            foreach ($ar3 as $kq => $vq) {
                                $yu[] = $vq . ',' . $vq;
                            }
                            foreach ($yu as $kk => $vv) {
                                foreach ($ar5 as $kc => $vc) {
                                    $ts = explode(",", $vv);
                                    sort($ts);
                                    if (!in_array($vc, $ts)) {
                                        $ts[] = $vc;
                                        $ttt[] = implode(",", $ts);
                                    }
                                }
                            }
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($ttt as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ar2 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $ar5 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $yu = array();
                            $ttt = array();
                            $ar6 = getCombinationToString($ar5, 2);
                            foreach ($ar2 as $kq => $vq) {
                                $yu[] = $vq . ',' . $vq . ',' . $vq;
                            }
                            foreach ($yu as $kk => $vv) {
                                foreach ($ar6 as $kc => $vc) {
                                    $ts = explode(",", $vv);
                                    sort($ts);
                                    $vs = explode(",", $vc);
                                    if (!in_array($vs[0], $ts) && !in_array($vs[1], $ts)) {
                                        $ts[] = $vc;
                                        $ttt[] = implode(",", $ts);
                                    }
                                }
                            }
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($ttt as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ar2 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $ar5 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $yu = array();
                            $ttt = array();
                            foreach ($ar2 as $kq => $vq) {
                                $yu[] = $vq . ',' . $vq . ',' . $vq;
                            }
                            foreach ($yu as $kk => $vv) {
                                foreach ($ar5 as $kc => $vc) {
                                    $ts = explode(",", $vv);
                                    sort($ts);
                                    if (!in_array($vc, $ts)) {
                                        $ts[] = $vc . ',' . $vc;
                                        $ttt[] = implode(",", $ts);
                                    }
                                }
                            }
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($ttt as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ar2 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $ar5 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $yu = array();
                            $ttt = array();
                            foreach ($ar2 as $kq => $vq) {
                                $yu[] = $vq . ',' . $vq . ',' . $vq . ',' . $vq;
                            }
                            foreach ($yu as $kk => $vv) {
                                foreach ($ar5 as $kc => $vc) {
                                    $ts = explode(",", $vv);
                                    sort($ts);
                                    if (!in_array($vc, $ts)) {
                                        $ts[] = $vc;
                                        $ttt[] = implode(",", $ts);
                                    }
                                }
                            }
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($ttt as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '9' || $v['m_type'] == '12') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", $resu['opencode']);
                            foreach ($ar1 as $kk => $vv) {
                                if (in_array($vv, $nt)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '10') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 2);
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            foreach ($ar2 as $kk => $vv) {
                                $ca = explode(",", $vv);
                                if (in_array($ca[0], $nt)) {
                                    if (in_array($ca[1], $nt)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        //三码不定位
                        if ($v['m_type'] == '11') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 3);
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            foreach ($ar2 as $kk => $vv) {
                                $ca = explode(",", $vv);
                                if (in_array($ca[0], $nt)) {
                                    if (in_array($ca[1], $nt)) {
                                        if (in_array($ca[2], $nt)) {
                                            //中奖
                                            $zid[] = $v['id'];
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        //好事成双
                        if ($v['m_type'] == '13') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $rt = array_count_values($nt);
                            foreach ($rt as $ka => $va) {
                                if ($va < 2) {
                                    unset($rt[$ka]);
                                }
                            }
                            foreach ($ar1 as $kk => $vv) {
                                foreach ($rt as $kc => $vc) {
                                    if ($vv == $kc) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }

                            }
                        }
                        if ($v['m_type'] == '14') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $rt = array_count_values($nt);
                            foreach ($rt as $ka => $va) {
                                if ($va < 3) {
                                    unset($rt[$ka]);
                                }
                            }
                            foreach ($ar1 as $kk => $vv) {
                                foreach ($rt as $kc => $vc) {
                                    if ($vv == $kc) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }

                            }
                        }
                        if ($v['m_type'] == '15') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $rt = array_count_values($nt);
                            foreach ($rt as $ka => $va) {
                                if ($va < 4) {
                                    unset($rt[$ka]);
                                }
                            }
                            foreach ($ar1 as $kk => $vv) {
                                foreach ($rt as $kc => $vc) {
                                    if ($vv == $kc) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }

                            }
                        }
                    }
                    //四星
                    if ($v['type'] == '2') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $pa1 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $pa2 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $pa3 = explode(",", str_replace(" ", ",", $ar1[2]));
                            $pa4 = explode(",", str_replace(" ", ",", $ar1[3]));
                            $narr = array();
                            foreach ($pa1 as $ka => $va) {
                                foreach ($pa2 as $kb => $vb) {
                                    foreach ($pa3 as $kc => $vc) {
                                        foreach ($pa4 as $kq => $vq) {
                                            if ($va && $vb && $vc && $vq) {
                                                $narr[] = $va . ',' . $vb . ',' . $vc . ',' . $vq;
                                            }
                                        }
                                    }
                                }
                            }
                            foreach ($narr as $ki => $vi) {
                                $ts = explode(",", $vi);
                                sort($ts);
                                $narr[$ki] = implode(",", $ts);
                            }
                            $op = explode(",", substr($resu['opencode'], 2));
                            sort($op);
                            $nstr = implode(",", $op);
                            if (in_array($nstr, $narr)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $aa = str_replace(",", "", substr($resu['opencode'], 2));
                            foreach ($ar1 as $ki => $vi) {
                                if ($vi === $aa) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 4);
                            $aa = explode(",", substr($resu['opencode'], 2));
                            sort($aa);
                            $bb = implode(",", $aa);
                            foreach ($ar2 as $ki => $vi) {
                                if ($vi === $bb) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ar2 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $ar5 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $yu = array();
                            $ttt = array();
                            $ar6 = getCombinationToString($ar5, 2);
                            foreach ($ar2 as $kq => $vq) {
                                $yu[] = $vq . ',' . $vq;
                            }
                            foreach ($yu as $kk => $vv) {
                                foreach ($ar6 as $kc => $vc) {
                                    $ts = explode(",", $vv);
                                    sort($ts);
                                    $vs = explode(",", $vc);
                                    if (!in_array($vs[0], $ts) && !in_array($vs[1], $ts)) {
                                        $ts[] = $vc;
                                        $ttt[] = implode(",", $ts);
                                    }
                                }
                            }
                            $nt = explode(",", substr($resu['opencode'], 2));
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($ttt as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $yu = array();
                            $ar6 = getCombinationToString($ar1, 2);
                            foreach ($ar6 as $kq => $vq) {
                                $ts = explode(",", $vq);
                                $yu[] = $ts[0] . ',' . $ts[0] . ',' . $ts[1] . ',' . $ts[1];
                            }
                            $nt = explode(",", substr($resu['opencode'], 2));
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($yu as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ar2 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $ar5 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $yu = array();
                            $ttt = array();
                            foreach ($ar2 as $kq => $vq) {
                                $yu[] = $vq . ',' . $vq . ',' . $vq;
                            }
                            foreach ($yu as $kk => $vv) {
                                foreach ($ar5 as $kc => $vc) {
                                    $ts = explode(",", $vv);
                                    if (!in_array($vc, $ts)) {
                                        $ts[] = $vc;
                                        sort($ts);
                                        $ttt[] = implode(",", $ts);
                                    }
                                }
                            }
                            $nt = explode(",", substr($resu['opencode'], 2));
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($ttt as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", substr($resu['opencode'], 2));
                            foreach ($ar1 as $kk => $vv) {
                                if (in_array($vv, $nt)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 2);
                            $nt = explode(",", substr($resu['opencode'], 2));
                            sort($nt);
                            foreach ($ar2 as $kk => $vv) {
                                $ca = explode(",", $vv);
                                if (in_array($ca[0], $nt)) {
                                    if (in_array($ca[1], $nt)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    //前三
                    if ($v['type'] == '3') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $pa1 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $pa2 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $pa3 = explode(",", str_replace(" ", ",", $ar1[2]));
                            $narr = array();
                            foreach ($pa1 as $ka => $va) {
                                foreach ($pa2 as $kb => $vb) {
                                    foreach ($pa3 as $kc => $vc) {
                                        if ($va && $vb && $vc) {
                                            $narr[] = $va . ',' . $vb . ',' . $vc;
                                        }
                                    }
                                }
                            }
                            $op = explode(",", $resu['opencode']);
                            $nstr = implode(",", $op);
                            if (in_array(substr($nstr, 0, 5), $narr)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $cc = str_replace(",", "", substr($resu['opencode'], 0, 5));
                            if (in_array($cc, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            $he = $cc[0] + $cc[1] + $cc[2];
                            if (in_array($he, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            sort($cc);
                            $cha = $cc[2] - $cc[0];
                            if (in_array($cha, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            if ($cc[0] != $cc[1] && $cc[1] != $cc[2]) {
                                $cha = $cc[0] + $cc[1] + $cc[2];
                                if (in_array($cha, $ar1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nr = array();
                            foreach ($ar1 as $kk => $vv) {
                                $nr[] = $vv . ',' . $vv;
                            }
                            $cr = array();
                            foreach ($nr as $key => $value) {
                                $vt = explode(",", $value);
                                foreach ($ar1 as $ka => $va) {
                                    if (!in_array($va, $vt)) {
                                        $cr[] = $value . ',' . $va;
                                    }
                                }
                            }
                            foreach ($cr as $ky => $vy) {
                                $tu = explode(",", $vy);
                                sort($tu);
                                $cr[$ky] = implode(",", $tu);
                            }
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            sort($cc);
                            $ch = implode(",", $cc);
                            foreach ($cr as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cp = getCombinationToString($ar1, 3);
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            sort($cc);
                            $ch = implode(",", $cc);
                            foreach ($cp as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            foreach ($ar1 as $kk => $vv) {
                                $ca = substr_cut($vv);
                                sort($ca);
                                $ar1[$kk] = str_replace(",", "", implode(",", $ca));
                            }
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            sort($cc);
                            $ch = str_replace(",", "", implode(",", $cc));
                            foreach ($ar1 as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '9') {
                            $ar = trim($v['cal']);
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            if ($cc[0] != $cc[1]) {
                                sort($cc);
                                foreach ($cc as $ki => $vi) {
                                    if ($ar === $vi) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '10' || $v['m_type'] == '11') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            foreach ($ar1 as $kk => $vv) {
                                $ca = substr_cut($vv);
                                sort($ca);
                                $ar1[$kk] = str_replace(",", "", implode(",", $ca));
                            }
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            sort($cc);
                            $ch = str_replace(",", "", implode(",", $cc));
                            foreach ($ar1 as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '12') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", substr($resu['opencode'], 0, 5));
                            foreach ($ar1 as $kk => $vv) {
                                if (in_array($vv, $nt)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '13') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 2);
                            $nt = explode(",", substr($resu['opencode'], 0, 5));
                            sort($nt);
                            foreach ($ar2 as $kk => $vv) {
                                $ca = explode(",", $vv);
                                if (in_array($ca[0], $nt)) {
                                    if (in_array($ca[1], $nt)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    //中三
                    if ($v['type'] == '4') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $pa1 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $pa2 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $pa3 = explode(",", str_replace(" ", ",", $ar1[2]));
                            $narr = array();
                            foreach ($pa1 as $ka => $va) {
                                foreach ($pa2 as $kb => $vb) {
                                    foreach ($pa3 as $kc => $vc) {
                                        if ($va && $vb && $vc) {
                                            $narr[] = $va . ',' . $vb . ',' . $vc;
                                        }
                                    }
                                }
                            }
                            $op = explode(",", $resu['opencode']);
                            $nstr = implode(",", $op);
                            if (in_array(substr($nstr, 2, 5), $narr)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $cc = str_replace(",", "", substr($resu['opencode'], 2, 5));
                            if (in_array($cc, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            $he = $cc[0] + $cc[1] + $cc[2];
                            if (in_array($he, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            sort($cc);
                            $cha = $cc[2] - $cc[0];
                            if (in_array($cha, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            if ($cc[0] != $cc[1] && $cc[1] != $cc[2]) {
                                $cha = $cc[0] + $cc[1] + $cc[2];
                                if (in_array($cha, $ar1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nr = array();
                            foreach ($ar1 as $kk => $vv) {
                                $nr[] = $vv . ',' . $vv;
                            }
                            $cr = array();
                            foreach ($nr as $key => $value) {
                                $vt = explode(",", $value);
                                foreach ($ar1 as $ka => $va) {
                                    if (!in_array($va, $vt)) {
                                        $cr[] = $value . ',' . $va;
                                    }
                                }
                            }
                            foreach ($cr as $ky => $vy) {
                                $tu = explode(",", $vy);
                                sort($tu);
                                $cr[$ky] = implode(",", $tu);
                            }
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            sort($cc);
                            $ch = implode(",", $cc);
                            foreach ($cr as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cp = getCombinationToString($ar1, 3);
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            sort($cc);
                            $ch = implode(",", $cc);
                            foreach ($cp as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            foreach ($ar1 as $kk => $vv) {
                                $ca = substr_cut($vv);
                                sort($ca);
                                $ar1[$kk] = str_replace(",", "", implode(",", $ca));
                            }
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            sort($cc);
                            $ch = str_replace(",", "", implode(",", $cc));
                            foreach ($ar1 as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '9') {
                            $ar = trim($v['cal']);
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            if ($cc[0] != $cc[1]) {
                                sort($cc);
                                foreach ($cc as $ki => $vi) {
                                    if ($ar === $vi) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '10' || $v['m_type'] == '11') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            foreach ($ar1 as $kk => $vv) {
                                $ca = substr_cut($vv);
                                sort($ca);
                                $ar1[$kk] = str_replace(",", "", implode(",", $ca));
                            }
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            sort($cc);
                            $ch = str_replace(",", "", implode(",", $cc));
                            foreach ($ar1 as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '12') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", substr($resu['opencode'], 2, 5));
                            foreach ($ar1 as $kk => $vv) {
                                if (in_array($vv, $nt)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '13') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 2);
                            $nt = explode(",", substr($resu['opencode'], 2, 5));
                            sort($nt);
                            foreach ($ar2 as $kk => $vv) {
                                $ca = explode(",", $vv);
                                if (in_array($ca[0], $nt)) {
                                    if (in_array($ca[1], $nt)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    //后三
                    if ($v['type'] == '5') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $pa1 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $pa2 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $pa3 = explode(",", str_replace(" ", ",", $ar1[2]));
                            $narr = array();
                            foreach ($pa1 as $ka => $va) {
                                foreach ($pa2 as $kb => $vb) {
                                    foreach ($pa3 as $kc => $vc) {
                                        if ($va && $vb && $vc) {
                                            $narr[] = $va . ',' . $vb . ',' . $vc;
                                        }
                                    }
                                }
                            }
                            $op = explode(",", $resu['opencode']);
                            $nstr = implode(",", $op);
                            if (in_array(substr($nstr, 4), $narr)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $cc = str_replace(",", "", substr($resu['opencode'], 4));
                            if (in_array($cc, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 4));
                            $he = $cc[0] + $cc[1] + $cc[2];
                            if (in_array($he, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 4));
                            sort($cc);
                            $cha = $cc[2] - $cc[0];
                            if (in_array($cha, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 4));
                            if ($cc[0] != $cc[1] && $cc[1] != $cc[2]) {
                                $cha = $cc[0] + $cc[1] + $cc[2];
                                if (in_array($cha, $ar1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nr = array();
                            foreach ($ar1 as $kk => $vv) {
                                $nr[] = $vv . ',' . $vv;
                            }
                            $cr = array();
                            foreach ($nr as $key => $value) {
                                $vt = explode(",", $value);
                                foreach ($ar1 as $ka => $va) {
                                    if (!in_array($va, $vt)) {
                                        $cr[] = $value . ',' . $va;
                                    }
                                }
                            }
                            foreach ($cr as $ky => $vy) {
                                $tu = explode(",", $vy);
                                sort($tu);
                                $cr[$ky] = implode(",", $tu);
                            }
                            $cc = explode(",", substr($resu['opencode'], 4));
                            sort($cc);
                            $ch = implode(",", $cc);
                            foreach ($cr as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cp = getCombinationToString($ar1, 3);
                            $cc = explode(",", substr($resu['opencode'], 4));
                            sort($cc);
                            $ch = implode(",", $cc);
                            foreach ($cp as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            foreach ($ar1 as $kk => $vv) {
                                $ca = substr_cut($vv);
                                sort($ca);
                                $ar1[$kk] = str_replace(",", "", implode(",", $ca));
                            }
                            $cc = explode(",", substr($resu['opencode'], 4));
                            sort($cc);
                            $ch = str_replace(",", "", implode(",", $cc));
                            foreach ($ar1 as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '9') {
                            $ar = trim($v['cal']);
                            $cc = explode(",", substr($resu['opencode'], 4));
                            if ($cc[0] != $cc[1]) {
                                sort($cc);
                                foreach ($cc as $ki => $vi) {
                                    if ($ar === $vi) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '10' || $v['m_type'] == '11') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            foreach ($ar1 as $kk => $vv) {
                                $ca = substr_cut($vv);
                                sort($ca);
                                $ar1[$kk] = str_replace(",", "", implode(",", $ca));
                            }
                            $cc = explode(",", substr($resu['opencode'], 4));
                            sort($cc);
                            $ch = str_replace(",", "", implode(",", $cc));
                            foreach ($ar1 as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '12') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", substr($resu['opencode'], 4));
                            foreach ($ar1 as $kk => $vv) {
                                if (in_array($vv, $nt)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '13') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 2);
                            $nt = explode(",", substr($resu['opencode'], 4));
                            sort($nt);
                            foreach ($ar2 as $kk => $vv) {
                                $ca = explode(",", $vv);
                                if (in_array($ca[0], $nt)) {
                                    if (in_array($ca[1], $nt)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    //前二
                    if ($v['type'] == '6') {
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr1 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr1[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr1[1]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    $qu[] = $v1 . ',' . $v2;
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 3) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $a = rtrim($v['cal']);
                            $ar1 = explode(",", $a);
                            $aa = str_replace(",", "", substr($resu['opencode'], 0, 3));
                            foreach ($ar1 as $kk => $vv) {
                                if ($aa === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $aa = explode(",", substr($resu['opencode'], 0, 3));
                            $he = $aa[0] + $aa[1];
                            if (in_array($he, $a)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $aa = explode(",", substr($resu['opencode'], 0, 3));
                            sort($aa);
                            $he = $aa[1] - $aa[0];
                            if (in_array($he, $a)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nar = getCombinationToString($a, 2);
                            $aa = explode(",", substr($resu['opencode'], 0, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                $bb = implode(",", $aa);
                                foreach ($nar as $ka => $va) {
                                    if ($bb === $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $a = explode(",", rtrim($v['cal']));
                            $aa = explode(",", substr($resu['opencode'], 0, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                $bb = str_replace(",", "", implode(",", $aa));
                                foreach ($a as $ka => $va) {
                                    if ($bb === $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $aa = explode(",", substr($resu['opencode'], 0, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                $bb = $aa[0] + $aa[1];
                                foreach ($a as $ka => $va) {
                                    if ($bb == $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $a = rtrim($v['cal']);
                            $aa = explode(",", substr($resu['opencode'], 0, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                foreach ($aa as $ka => $va) {
                                    if ($a == $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    //后二
                    if ($v['type'] == '7') {
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr1 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr1[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr1[1]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    $qu[] = $v1 . ',' . $v2;
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 6, 3) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $a = rtrim($v['cal']);
                            $ar1 = explode(",", $a);
                            $aa = str_replace(",", "", substr($resu['opencode'], 6, 3));
                            foreach ($ar1 as $kk => $vv) {
                                if ($aa === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $aa = explode(",", substr($resu['opencode'], 6, 3));
                            $he = $aa[0] + $aa[1];
                            if (in_array($he, $a)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $aa = explode(",", substr($resu['opencode'], 6, 3));
                            sort($aa);
                            $he = $aa[1] - $aa[0];
                            if (in_array($he, $a)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nar = getCombinationToString($a, 2);
                            $aa = explode(",", substr($resu['opencode'], 6, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                $bb = implode(",", $aa);
                                foreach ($nar as $ka => $va) {
                                    if ($bb === $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $a = explode(",", rtrim($v['cal']));
                            $aa = explode(",", substr($resu['opencode'], 6, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                $bb = str_replace(",", "", implode(",", $aa));
                                foreach ($a as $ka => $va) {
                                    if ($bb === $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $aa = explode(",", substr($resu['opencode'], 6, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                $bb = $aa[0] + $aa[1];
                                foreach ($a as $ka => $va) {
                                    if ($bb == $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $a = rtrim($v['cal']);
                            $aa = explode(",", substr($resu['opencode'], 6, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                foreach ($aa as $ka => $va) {
                                    if ($a == $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    //一星
                    if ($v['type'] == '8') {
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr1 = explode(",", $a);
                            $arr2 = explode(",", $resu['opencode']);
                            for ($i = 0; $i < 5; $i++) {
                                if (isset($arr1[$i])) {
                                    $ara = explode(",", str_replace(" ", ",", $arr1[$i]));
                                    if (in_array($arr2[$i], $ara)) {
                                        $zid[] = $v['id'];
                                        continue;
                                    } else {
                                        continue;
                                    }
                                }
                            }
                            $zid = array_unique($zid);
                        }
                    }
                    if ($v['type'] == '9') {
                        if ($v['m_type'] == '1') {
                            $n = explode(",", rtrim($v['cal']));
                            $qian = explode(",", str_replace(" ", ",", $n[0]));
                            $hou = explode(",", str_replace(" ", ",", $n[1]));
                            $arrt = explode(",", substr($resu['opencode'], 0, 3));
                            if ($arrt[0] >= 0 && $arrt[0] <= 4) {
                                $str[] = "小";
                            }
                            if ($arrt[0] >= 5 && $arrt[0] <= 9) {
                                $str[] = "大";
                            }
                            if ($arrt[0] % 2 == 0) {
                                $str[] = "双";
                            } else {
                                $str[] = "单";
                            }
                            if ($arrt[1] >= 0 && $arrt[1] <= 4) {
                                $s[] = "小";
                            }
                            if ($arrt[1] >= 5 && $arrt[1] <= 9) {
                                $s[] = "大";
                            }
                            if ($arrt[1] % 2 == 0) {
                                $s[] = "双";
                            } else {
                                $s[] = "单";
                            }
                            foreach ($qian as $ka => $va) {
                                if (in_array($va, $str)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            foreach ($hou as $ka1 => $va1) {
                                if (in_array($va1, $s)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }

                            $zid = array_unique($zid);
                        }
                        if ($v['m_type'] == '2') {
                            $n = explode(",", rtrim($v['cal']));
                            $qian = explode(",", str_replace(" ", ",", $n[0]));
                            $hou = explode(",", str_replace(" ", ",", $n[1]));
                            $arrt = explode(",", substr($resu['opencode'], 6, 3));
                            if ($arrt[0] >= 0 && $arrt[0] <= 4) {
                                $str[] = "小";
                            }
                            if ($arrt[0] >= 5 && $arrt[0] <= 9) {
                                $str[] = "大";
                            }
                            if ($arrt[0] % 2 == 0) {
                                $str[] = "双";
                            } else {
                                $str[] = "单";
                            }
                            if ($arrt[1] >= 0 && $arrt[1] <= 4) {
                                $s[] = "小";
                            }
                            if ($arrt[1] >= 5 && $arrt[1] <= 9) {
                                $s[] = "大";
                            }
                            if ($arrt[1] % 2 == 0) {
                                $s[] = "双";
                            } else {
                                $s[] = "单";
                            }
                            foreach ($qian as $ka => $va) {
                                if (in_array($va, $str)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            foreach ($hou as $ka1 => $va1) {
                                if (in_array($va1, $s)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            $zid = array_unique($zid);
                        }
                        if ($v['m_type'] == '3') {
                            $n = explode(",", rtrim($v['cal']));
                            $qian = explode(",", str_replace(" ", ",", $n[0]));
                            $zhong = explode(",", str_replace(" ", ",", $n[1]));
                            $hou = explode(",", str_replace(" ", ",", $n[2]));
                            $arrt = explode(",", substr($resu['opencode'], 0, 5));
                            if ($arrt[0] >= 0 && $arrt[0] <= 4) {
                                $str[] = "小";
                            }
                            if ($arrt[0] >= 5 && $arrt[0] <= 9) {
                                $str[] = "大";
                            }
                            if ($arrt[0] % 2 == 0) {
                                $str[] = "双";
                            } else {
                                $str[] = "单";
                            }
                            if ($arrt[1] >= 0 && $arrt[1] <= 4) {
                                $s[] = "小";
                            }
                            if ($arrt[1] >= 5 && $arrt[1] <= 9) {
                                $s[] = "大";
                            }
                            if ($arrt[1] % 2 == 0) {
                                $s[] = "双";
                            } else {
                                $s[] = "单";
                            }
                            if ($arrt[2] >= 0 && $arrt[2] <= 4) {
                                $s1[] = "小";
                            }
                            if ($arrt[2] >= 5 && $arrt[2] <= 9) {
                                $s1[] = "大";
                            }
                            if ($arrt[2] % 2 == 0) {
                                $s1[] = "双";
                            } else {
                                $s1[] = "单";
                            }
                            foreach ($qian as $ka => $va) {
                                if (in_array($va, $str)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            foreach ($zhong as $ka1 => $va1) {
                                if (in_array($va1, $s)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            foreach ($hou as $ka1 => $va1) {
                                if (in_array($va1, $s1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            $zid = array_unique($zid);
                        }
                        if ($v['m_type'] == '4') {
                            $n = explode(",", rtrim($v['cal']));
                            $qian = explode(",", str_replace(" ", ",", $n[0]));
                            $zhong = explode(",", str_replace(" ", ",", $n[1]));
                            $hou = explode(",", str_replace(" ", ",", $n[2]));
                            $arrt = explode(",", substr($resu['opencode'], 4));
                            if ($arrt[0] >= 0 && $arrt[0] <= 4) {
                                $str[] = "小";
                            }
                            if ($arrt[0] >= 5 && $arrt[0] <= 9) {
                                $str[] = "大";
                            }
                            if ($arrt[0] % 2 == 0) {
                                $str[] = "双";
                            } else {
                                $str[] = "单";
                            }
                            if ($arrt[1] >= 0 && $arrt[1] <= 4) {
                                $s[] = "小";
                            }
                            if ($arrt[1] >= 5 && $arrt[1] <= 9) {
                                $s[] = "大";
                            }
                            if ($arrt[1] % 2 == 0) {
                                $s[] = "双";
                            } else {
                                $s[] = "单";
                            }
                            if ($arrt[2] >= 0 && $arrt[2] <= 4) {
                                $s1[] = "小";
                            }
                            if ($arrt[2] >= 5 && $arrt[2] <= 9) {
                                $s1[] = "大";
                            }
                            if ($arrt[2] % 2 == 0) {
                                $s1[] = "双";
                            } else {
                                $s1[] = "单";
                            }
                            foreach ($qian as $ka => $va) {
                                if (in_array($va, $str)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            foreach ($zhong as $ka1 => $va1) {
                                if (in_array($va1, $s)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            foreach ($hou as $ka1 => $va1) {
                                if (in_array($va1, $s1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            $zid = array_unique($zid);
                        }
                    }
                    $jieg[] = array($v['id'] => $resu['opencode']);
                }
            }
            $temp = array();
            foreach ($jieg as $kg => $vg) {
                foreach ($vg as $kt => $vt) {
                    if (!in_array($kt, $temp)) {
                        $temp[$kt] = $vt;
                    }
                }
            }
            $sq = "";
            foreach ($temp as $ki => $vi) {
                $sq .= " when id = {$ki} then '{$vi}' ";
            }
            $sql = "";
            if (!empty($sq)) {
                $sql .= ",opencode = CASE {$sq} else opencode end ";
            }
            if (!empty($sql)) {
                $sql = trim($sql, ',');
                $sql = "update " . C("DB_PREFIX") . "zhui_ssc_detail set {$sql}";
                M()->execute($sql);
            }
            foreach ($house999 as $k1 => $v1) {
                foreach ($arr as $ka => $va) {
                    if (array_search(trim($v1['issue']), $va)) {
                        if (!in_array($v1['id'], $zid)) {
                            $wz[] = $v1['id'];
                        }
                        break;
                    }
                }
            }
            if (!empty($wz)) {
                $ccd = implode(",", $wz);
                //	M("zhui_ssc_detail")->where("id in($ccd)")->save(array("is_zhong"=>2));
            }
            if (!empty($zid)) {
                $zd = implode(",", $zid);
                M("zhui_ssc_detail")->where("id in($zd)")->save(array("is_zhong" => 1));
                $res = M("zhui_ssc_detail d")
                    ->join(" join " . C("DB_PREFIX") . "zhui_ssc s on d.zhui_ssc_id=s.id")
                    ->where("d.id in($zd)")
                    ->field("d.id,d.zhui_ssc_id,d.zhong_money,s.uid,s.is_ting,s.z_type2,s.z_type,s.lv1,s.lv2_qi,s.lv2,s.lv3,s.moneys")
                    ->select();
                foreach ($res as $kz => $vz) {
                    $uu[] = $vz['uid'];
                }
                $uz = implode(",", $uu);
                if ($uz) {
                    $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                }
                foreach ($res as $kp1 => $vp1) {
                    foreach ($mo as $kp2 => $vp2) {
                        if ($vp1['uid'] == $vp2['userid']) {
                            $res[$kp1]['money'] = $vp2['money'];
                        }
                    }
                }
                foreach ($res as $kb => $vb) {
                    if ($vb['is_ting'] == '1') {
                        $p1[] = $vb['id'];
                    }
                    if ($vb['is_ting'] == '2') {
                        $p2[] = $vb['id'];
                    }
                    if ($vb['z_type2'] == '1' || $vb['z_type2'] == '2') {
                        $p3[] = $vb['id'];
                    }
                }
                if ($p1) {
                    $zd = implode(",", $p1);
                    M("zhui_ssc_detail")->where("id in($zd)")->save(array("is_zhong" => 1));
                    $res1 = M("zhui_ssc_detail d")
                        ->join(" join " . C("DB_PREFIX") . "zhui_ssc s on d.zhui_ssc_id=s.id")
                        ->where("d.id in($zd)")
                        //	->field("d.zhui_ssc_id,d.zhong_money,s.uid")
                        ->field(array("d.*,s.lotteryclass,s.uid"))
                        ->select();
                    foreach ($res1 as $k98 => $v98) {
                        if ($v98['lotteryclass'] == '15') {
                            $arr = $this->get_data2("cqssc");
                            if (empty($arr)) {
                                $arr = $this->ren_gong($ren_gong, 15, $v['issue']);
                            }
                        }
                        if ($v98['lotteryclass'] == '17') {
                            $arr = $this->get_data("xjssc");
                            if (empty($arr)) {
                                $arr = $this->ren_gong($ren_gong, 17, $v['issue']);
                            }
                        }
                        if ($v98['lotteryclass'] == '18') {
                            $arr = $this->get_data2("tjssc");
                            if (empty($arr)) {
                                $arr = $this->ren_gong($ren_gong, 18, $v['issue']);
                            }
                        }
                        if ($v98['lotteryclass'] == '19') {
                            $arr = $this->get_data("ffc2");
                            if (empty($arr)) {
                                $arr = $this->ren_gong($ren_gong, 19, $v['issue']);
                            }
                        }
                        foreach ($arr as $ka => $va) {
                            if (array_search(trim($v98['issue']), $va)) {
                                $resu = $arr[$ka];
                                break;
                            }
                        }
                        if (!empty($resu)) {
                            if ($v98['type'] == '8') {
                                $zj = 0;
                                $a = rtrim($v98['cal']);
                                $arr1 = explode(",", $a);
                                $arr2 = explode(",", $resu['opencode']);
                                for ($i = 0; $i < 5; $i++) {
                                    if (!empty($arr1[$i])) {
                                        $ara = explode(",", str_replace(" ", ",", $arr1[$i]));
                                        if (in_array($arr2[$i], $ara)) {
                                            $zj++;
                                            continue;
                                        } else {
                                            continue;
                                        }
                                    }
                                }
                                $res1[$k98]['zhong_money'] = $zj * $v98['zhong_money'];
                            }
                        }
                    }
                    foreach ($res1 as $kz => $vz) {
                        $uu[] = $vz['uid'];
                    }
                    $uz = implode(",", $uu);
                    if ($uz) {
                        $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                    }
                    foreach ($res1 as $kp1 => $vp1) {
                        foreach ($mo as $kp2 => $vp2) {
                            if ($vp1['uid'] == $vp2['userid']) {
                                $res1[$kp1]['money'] = $vp2['money'];
                            }
                        }
                    }
                    foreach ($res1 as $kp => $vp) {
                        $zz[] = $vp['zhui_ssc_id'];
                        $uudd[] = $vp['uid'];
                        $history_date[] = array(
                            'number' => date("Ymd") . rand(100000, 999999),
                            'type' => '5',
                            'shou_money' => $vp['zhong_money'],
                            'ky_money' => $vp['money'],
                            'ctime' => time(),
                            'uid' => $vp['uid'],
                            'remark' => '奖金派送'
                        );
                    }
                    $lad = implode(",", $zz);
                    $udd = implode(",", $uudd);
                    $result = array();
                    foreach ($res1 as $ke1 => $info) {
                        if ($result[$info['zhui_ssc_id']]) {
                            $result[$info['zhui_ssc_id']] += $info['zhong_money'];
                        } else {
                            $result[$info['zhui_ssc_id']] = trim($info['zhong_money']);
                        }
                    }
                    $result1 = array();
                    foreach ($res1 as $ke2 => $info2) {
                        if ($result1[$info2['uid']]) {
                            $result1[$info2['uid']] += $info2['zhong_money'];
                        } else {
                            $result1[$info2['uid']] = trim($info2['zhong_money']);
                        }
                    }
                    foreach ($result1 as $kwi => $vwi) {
                        foreach ($mo as $k11 => $v11) {
                            if ($kwi == $v11['userid']) {
                                $result1[$kwi] = $vwi + $v11['money'];
                            }
                        }
                    }
                    $sq = "";
                    $sq1 = "";
                    foreach ($result as $ki => $vi) {
                        $sq .= " when id = {$ki} then '{$vi}' ";
                    }
                    foreach ($result1 as $ki1 => $vi1) {
                        $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                    }
                    $sql = "";
                    if (!empty($sq)) {
                        $sql .= ",zo_money = CASE {$sq} else zo_money end ";
                    }
                    $sql1 = "";
                    if (!empty($sq1)) {
                        $sql1 .= ",money = CASE {$sq1} else money end ";
                    }
                    if (!empty($sql)) {
                        $sql = trim($sql, ',');
                        $sql = "update " . C("DB_PREFIX") . "zhui_ssc set {$sql}";
                        M()->execute($sql);
                    }
                    if (!empty($sql1)) {
                        $sql1 = trim($sql1, ',');
                        $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                        M()->execute($sql1);
                    }
                    M("jiaoyi")->addAll($history_date);
                    //停止追号
                    $ttt = M("zhui_ssc_detail xd")
                        ->join(" join " . C("DB_PREFIX") . "zhui_ssc a on xd.zhui_ssc_id=a.id")
                        ->where("xd.zhui_ssc_id in($lad) and xd.is_zhong=0 ")
                        ->field("a.uid,xd.touzhu_money,xd.id")
                        ->select();
                    $result3 = array();
                    $isr = array();
                    $tyu = array();
                    foreach ($ttt as $ke3 => $info3) {
                        $isr[] = $info3['id'];
                        $tyu[] = $info3['uid'];
                        if ($result3[$info3['uid']]) {
                            $result3[$info3['uid']] += $info3['touzhu_money'];
                        } else {
                            $result3[$info3['uid']] = trim($info3['touzhu_money']);
                        }
                    }
                    $irs = implode(",", $isr);
                    $dfg = implode(",", $tyu);
                    if ($dfg) {
                        $yy1 = M('Accountsinfo')->where("userid in($dfg)")->select();
                    }

                    foreach ($yy1 as $kp1 => $vp1) {
                        $tui = array($vp1['userid'] => $vp1['money'] + $result3[$vp1['userid']]);
                        $history_date2[] = array(
                            'number' => date("Ymd") . rand(100000, 999999),
                            'type' => '8',
                            'shou_money' => $result3[$vp1['userid']],
                            'ky_money' => $vp1['money'],
                            'ctime' => time(),
                            'uid' => $vp1['userid'],
                            'remark' => '追号停止'
                        );
                    }
                    M("jiaoyi")->addAll($history_date2);
                    M("zhui_ssc_detail")->where("id in($irs) and is_zhong=0 ")->save(array("is_zhong" => 3, 'opencode' => "追号停止"));
                    $sq2 = "";
                    foreach ($tui as $ki2 => $vi2) {
                        $sq2 .= " when userid = {$ki2} then '{$vi2}' ";
                    }
                    $sql2 = "";
                    if (!empty($sq2)) {
                        $sql2 .= ",money = CASE {$sq2} else money end ";
                    }
                    if (!empty($sql2)) {
                        $sql2 = trim($sql2, ',');
                        $sql2 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql2}";
                        M()->execute($sql2);
                    }
                }
                if ($p2) {
                    $zd2 = implode(",", $p2);
                    M("zhui_ssc_detail")->where("id in($zd2)")->save(array("is_zhong" => 1));
                    $res1 = M("zhui_ssc_detail d")
                        ->join(" join " . C("DB_PREFIX") . "zhui_ssc s on d.zhui_ssc_id=s.id")
                        ->where("d.id in($zd2)")
                        ->field("d.zhui_ssc_id,d.zhong_money,s.uid")
                        ->field(array("d.*,s.lotteryclass,s.uid"))
                        ->select();
                    foreach ($res1 as $k98 => $v98) {
                        if ($v98['lotteryclass'] == '15') {
                            $arr = $this->get_data2("cqssc");
                            if (empty($arr)) {
                                $arr = $this->ren_gong($ren_gong, 15, $v['issue']);
                            }
                        }
                        if ($v98['lotteryclass'] == '17') {
                            $arr = $this->get_data("xjssc");
                            if (empty($arr)) {
                                $arr = $this->ren_gong($ren_gong, 17, $v['issue']);
                            }
                        }
                        if ($v98['lotteryclass'] == '18') {
                            $arr = $this->get_data2("tjssc");
                            if (empty($arr)) {
                                $arr = $this->ren_gong($ren_gong, 18, $v['issue']);
                            }
                        }
                        if ($v98['lotteryclass'] == '19') {
                            $arr = $this->get_data("ffc2");
                            if (empty($arr)) {
                                $arr = $this->ren_gong($ren_gong, 19, $v['issue']);
                            }
                        }
                        foreach ($arr as $ka => $va) {
                            if (array_search(trim($v98['issue']), $va)) {
                                $resu = $arr[$ka];
                                break;
                            }
                        }
                        if (!empty($resu)) {
                            if ($v98['type'] == '8') {
                                $zj = 0;
                                $a = rtrim($v98['cal']);
                                $arr1 = explode(",", $a);
                                $arr2 = explode(",", $resu['opencode']);
                                for ($i = 0; $i < 5; $i++) {
                                    if (!empty($arr1[$i])) {
                                        $ara = explode(",", str_replace(" ", ",", $arr1[$i]));
                                        if (in_array($arr2[$i], $ara)) {
                                            $zj++;
                                            continue;
                                        } else {
                                            continue;
                                        }
                                    }
                                }
                                $res1[$k98]['zhong_money'] = $zj * $v98['zhong_money'];
                            }
                        }
                    }
                    foreach ($res1 as $kz => $vz) {
                        $uu[] = $vz['uid'];
                    }
                    $uz = implode(",", $uu);
                    if ($uz) {
                        $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                    }
                    foreach ($res1 as $kp1 => $vp1) {
                        foreach ($mo as $kp2 => $vp2) {
                            if ($vp1['uid'] == $vp2['userid']) {
                                $res1[$kp1]['money'] = $vp2['money'];
                            }
                        }
                    }
                    foreach ($res1 as $kp => $vp) {
                        $zz[] = $vp['zhui_ssc_id'];
                        $uudd[] = $vp['uid'];
                        $history_date3[] = array(
                            'number' => date("Ymd") . rand(100000, 999999),
                            'type' => '5',
                            'shou_money' => $vp['zhong_money'],
                            'ky_money' => $vp['money'],
                            'ctime' => time(),
                            'uid' => $vp['uid'],
                            'remark' => '奖金派送'
                        );
                    }
                    $lad = implode(",", $zz);
                    $udd = implode(",", $uudd);
                    $result = array();
                    foreach ($res1 as $ke1 => $info) {
                        if ($result[$info['zhui_ssc_id']]) {
                            $result[$info['zhui_ssc_id']] += $info['zhong_money'];
                        } else {
                            $result[$info['zhui_ssc_id']] = trim($info['zhong_money']);
                        }
                    }
                    $result1 = array();
                    foreach ($res1 as $ke2 => $info2) {
                        if ($result1[$info2['uid']]) {
                            $result1[$info2['uid']] += $info2['zhong_money'];
                        } else {
                            $result1[$info2['uid']] = trim($info2['zhong_money']);
                        }
                    }
                    foreach ($result1 as $kwi => $vwi) {
                        foreach ($mo as $k11 => $v11) {
                            if ($kwi == $v11['userid']) {
                                $result1[$kwi] = $vwi + $v11['money'];
                            }
                        }
                    }
                    $sq = "";
                    $sq1 = "";
                    foreach ($result as $ki => $vi) {
                        $sq .= " when id = {$ki} then '{$vi}' ";
                    }
                    foreach ($result1 as $ki1 => $vi1) {
                        $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                    }
                    $sql = "";
                    if (!empty($sq)) {
                        $sql .= ",zo_money = CASE {$sq} else zo_money end ";
                    }
                    $sql1 = "";
                    if (!empty($sq1)) {
                        $sql1 .= ",money = CASE {$sq1} else money end ";
                    }
                    if (!empty($sql)) {
                        $sql = trim($sql, ',');
                        $sql = "update " . C("DB_PREFIX") . "zhui_ssc set {$sql}";
                        M()->execute($sql);
                    }
                    if (!empty($sql1)) {
                        $sql1 = trim($sql1, ',');
                        $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                        M()->execute($sql1);
                    }
                    M("jiaoyi")->addAll($history_date3);
                }
                if ($p3) {
                    $hh = 0;
                    $hh1 = 0;
                    $hh2 = 0;
                    $zd = implode(",", $p3);
                    M("zhui_ssc_detail")->where("id in($zd)")->save(array("is_zhong" => 1));
                    $res1 = M("zhui_ssc_detail d")
                        ->join(" join " . C("DB_PREFIX") . "zhui_ssc s on d.zhui_ssc_id=s.id")
                        ->where("d.id in($zd)")
                        ->field("d.*,s.uid,s.z_type,s.moneys,s.lv1,s.lv2,s.lv3,s.lv2_qi,s.lotteryclass")
                        ->select();
                    foreach ($res1 as $k98 => $v98) {
                        if ($v98['lotteryclass'] == '15') {
                            $arr = $this->get_data2("cqssc");
                            if (empty($arr)) {
                                $arr = $this->ren_gong($ren_gong, 15, $v['issue']);
                            }
                        }
                        if ($v98['lotteryclass'] == '17') {
                            $arr = $this->get_data("xjssc");
                            if (empty($arr)) {
                                $arr = $this->ren_gong($ren_gong, 17, $v['issue']);
                            }
                        }
                        if ($v98['lotteryclass'] == '18') {
                            $arr = $this->get_data2("tjssc");
                            if (empty($arr)) {
                                $arr = $this->ren_gong($ren_gong, 18, $v['issue']);
                            }
                        }
                        if ($v98['lotteryclass'] == '19') {
                            $arr = $this->get_data("ffc2");
                            if (empty($arr)) {
                                $arr = $this->ren_gong($ren_gong, 19, $v['issue']);
                            }
                        }
                        foreach ($arr as $ka => $va) {
                            if (array_search(trim($v98['issue']), $va)) {
                                $resu = $arr[$ka];
                                break;
                            }
                        }
                        if (!empty($resu)) {
                            if ($v98['type'] == '8') {
                                $zj = 0;
                                $a = rtrim($v98['cal']);
                                $arr1 = explode(",", $a);
                                $arr2 = explode(",", $resu['opencode']);
                                for ($i = 0; $i < 5; $i++) {
                                    if (!empty($arr1[$i])) {
                                        $ara = explode(",", str_replace(" ", ",", $arr1[$i]));
                                        if (in_array($arr2[$i], $ara)) {
                                            $zj++;
                                            continue;
                                        } else {
                                            continue;
                                        }
                                    }
                                }
                                $res1[$k98]['zhong_money'] = $zj * $v98['zhong_money'];
                            }
                        }
                    }
                    foreach ($res1 as $kz => $vz) {
                        $uu[] = $vz['uid'];
                    }
                    $uz = implode(",", $uu);
                    if ($uz) {
                        $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                    }
                    foreach ($res1 as $kp1 => $vp1) {
                        foreach ($mo as $kp2 => $vp2) {
                            if ($vp1['uid'] == $vp2['userid']) {
                                $res1[$kp1]['money'] = $vp2['money'];
                            }
                        }
                    }
                    foreach ($res1 as $kp => $vp) {
                        $zz[] = $vp['zhui_ssc_id'];
                        $uudd[] = $vp['uid'];
                        $history_date5[] = array(
                            'number' => date("Ymd") . rand(100000, 999999),
                            'type' => '5',
                            'shou_money' => $vp['zhong_money'],
                            'ky_money' => $vp['money'],
                            'ctime' => time(),
                            'uid' => $vp['uid'],
                            'remark' => '奖金派送'
                        );
                    }
                    $lad = implode(",", $zz);
                    $udd = implode(",", $uudd);
                    $result = array();
                    foreach ($res1 as $ke1 => $info) {
                        if ($result[$info['zhui_ssc_id']]) {
                            $result[$info['zhui_ssc_id']] += $info['zhong_money'];
                        } else {
                            $result[$info['zhui_ssc_id']] = trim($info['zhong_money']);
                        }
                    }
                    $result1 = array();
                    foreach ($res1 as $ke2 => $info2) {
                        if ($result1[$info2['uid']]) {
                            $result1[$info2['uid']] += $info2['zhong_money'];
                        } else {
                            $result1[$info2['uid']] = trim($info2['zhong_money']);
                        }
                    }
                    foreach ($result1 as $kwi => $vwi) {
                        foreach ($mo as $k11 => $v11) {
                            if ($kwi == $v11['userid']) {
                                $result1[$kwi] = $vwi + $v11['money'];
                            }
                        }
                    }
                    $sq = "";
                    $sq1 = "";
                    foreach ($result as $ki => $vi) {
                        $sq .= " when id = {$ki} then '{$vi}' ";
                    }
                    foreach ($result1 as $ki1 => $vi1) {
                        $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                    }
                    $sql = "";
                    if (!empty($sq)) {
                        $sql .= ",zo_money = CASE {$sq} else zo_money end ";
                    }
                    $sql1 = "";
                    if (!empty($sq1)) {
                        $sql1 .= ",money = CASE {$sq1} else money end ";
                    }
                    if (!empty($sql)) {
                        $sql = trim($sql, ',');
                        $sql = "update " . C("DB_PREFIX") . "zhui_ssc set {$sql}";
                        M()->execute($sql);
                    }
                    if (!empty($sql1)) {
                        $sql1 = trim($sql1, ',');
                        $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                        M()->execute($sql1);
                    }
                    M("jiaoyi")->addAll($history_date5);
                    foreach ($res1 as $k2 => $v2) {
                        if ($v2['z_type'] == '1') {
                            $biaoz = ($v2['moneys'] * $v2['lv1']) / 100;
                            $myss[] = array(
                                'sid' => $v2['zhui_ssc_id'],
                                'moy' => $v2['zhong_money']
                            );
                            foreach ($myss as $kp => $vp) {
                                if ($vp['sid'] == $v2['zhui_ssc_id']) {
                                    $hh += $vp['moy'];
                                }
                            }
                            if ($hh >= $biaoz) {
                                //停止追号
                                $tz[] = $v['zhui_ssc_id'];
                                break;
                            }
                        }
                        if ($v2['z_type'] == '2') {
                            $biaoz1 = ($v2['moneys'] * $v2['lv2']) / 100;
                            $biaoz2 = ($v2['moneys'] * $v2['lv3']) / 100;
                            $myss[] = array(
                                'sid' => $v2['zhui_ssc_id'],
                                'moy' => $v2['zhong_money']
                            );
                            $posi = 1;
                            foreach ($myss as $kp => $vp) {
                                if ($posi < $v2['lv2_qi']) {
                                    if ($vp['sid'] == $v2['zhui_ssc_id']) {
                                        $hh1 += $vp['moy'];
                                    }
                                    $posi++;
                                } else {
                                    if ($vp['sid'] == $v2['zhui_ssc_id']) {
                                        $hh2 += $vp['moy'];
                                    }
                                }
                            }
                            if ($hh1 >= $biaoz1) {
                                //停止追号
                                $tz[] = $v['zhui_ssc_id'];
                                break;
                            } else {
                                if ($hh2 >= $biaoz2) {
                                    //停止追号
                                    $tz[] = $v['zhui_ssc_id'];
                                    break;
                                }
                            }
                        }
                    }
                    $tzz = implode(",", $tz);
                    if ($tzz) {
                        $ttt = M("zhui_ssc_detail xd")
                            ->join(" join " . C("DB_PREFIX") . "zhui_ssc a on xd.zhui_ssc_id=a.id")
                            ->where("xd.zhui_ssc_id in($lad) and xd.is_zhong=0 ")
                            ->field("a.uid,xd.touzhu_money,xd.id")
                            ->select();
                        $result3 = array();
                        $isr = array();
                        $tyu = array();
                        foreach ($ttt as $ke3 => $info3) {
                            $isr[] = $info3['id'];
                            $tyu[] = $info3['uid'];
                            if ($result3[$info3['uid']]) {
                                $result3[$info3['uid']] += $info3['touzhu_money'];
                            } else {
                                $result3[$info3['uid']] = trim($info3['touzhu_money']);
                            }
                        }
                        $irs = implode(",", $isr);
                        $dfg = implode(",", $tyu);
                        if ($dfg) {
                            $yy1 = M('Accountsinfo')->where("userid in($dfg)")->select();
                        }

                        foreach ($yy1 as $kp1 => $vp1) {
                            $tui = array($vp1['userid'] => $vp1['money'] + $result3[$vp1['userid']]);
                            $history_date22[] = array(
                                'number' => date("Ymd") . rand(100000, 999999),
                                'type' => '8',
                                'shou_money' => $result3[$vp1['userid']],
                                'ky_money' => $vp1['money'],
                                'ctime' => time(),
                                'uid' => $vp1['userid'],
                                'remark' => '追号停止'
                            );
                        }
                        M("jiaoyi")->addAll($history_date22);
                        M("zhui_ssc_detail")->where("id in($irs) and is_zhong=0 ")->save(array("is_zhong" => 3, 'opencode' => "追号停止"));
                        $sq2 = "";
                        foreach ($tui as $ki2 => $vi2) {
                            $sq2 .= " when userid = {$ki2} then '{$vi2}' ";
                        }
                        $sql2 = "";
                        if (!empty($sq2)) {
                            $sql2 .= ",money = CASE {$sq2} else money end ";
                        }
                        if (!empty($sql2)) {
                            $sql2 = trim($sql2, ',');
                            $sql2 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql2}";
                            M()->execute($sql2);
                        }
                    }
                }
            }
        }
    }

    //追号快乐8判断  1分钟1次
    public function zhui_kl8()
    {
        //------------------追号快乐8-------------------------------
        $wz = array();

        $house55 = M("zhui_kl8_detail a")
            ->join(" join " . C("DB_PREFIX") . "zhui_kl8 b on a.zhui_kl8_id = b.id")
            ->field(array("a.*,b.id as bid,b.lotteryclass,b.is_ting"))
            ->where("a.is_zhong = 0")
            ->select();
        $ren_gong = M("ren_gong")->where("1=1")->select();
        if (!empty($house55)) {
            foreach ($house55 as $k => $v) {
                $resu = array();
                $n = 0;
                $u = 0;
                $z = 0;
                $o = 0;
                $j = 0;
                $h = 0;
                $arrl = $this->get_data2("bjkl8");
                if (empty($arrl)) {
                    $arr1 = $this->ren_gong($ren_gong, 20, $v['issue']);
                }
                foreach ($arrl as $kc => $vc) {
                    $arrl[$kc]['issue'] = trim($vc['issue']);
                    $co = substr($vc['opencode'], 0, 59);
                    $arrl[$kc]['qu_code'] = $co;
                }
                foreach ($arrl as $ka => $va) {
                    if (array_search(trim($v['issue']), $va)) {
                        $resu = $arrl[$ka];
                        break;
                    }
                }
                if (!empty($resu)) {
                    //任选
                    if ($v['type'] == '1') {
                        //任选一
                        if ($v['m_type'] == '1') {
                            $au = trim(str_replace("+", ",", $resu['opencode']));
                            $arr = explode(",", $au);
                            $aa = rtrim($v['cal']);
                            $s = str_replace(" ", ",", $aa);
                            $a1 = explode(",", $s);
                            foreach ($a1 as $k1 => $v1) {
                                if (in_array($v1, $arr)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        //任选二
                        if ($v['m_type'] == '2') {
                            $au = trim(str_replace("+", ",", $resu['opencode']));
                            $arr = explode(",", $au);
                            $aa = rtrim($v['cal']);
                            $s = str_replace(" ", ",", $aa);
                            $a1 = explode(",", $s);
                            foreach ($a1 as $k1 => $v1) {
                                if (in_array($v1, $arr)) {
                                    $n++;
                                }
                            }
                            if ($n > 1) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        //任选三
                        if ($v['m_type'] == '3') {
                            $au = trim(str_replace("+", ",", $resu['opencode']));
                            $arr = explode(",", $au);
                            $aa = rtrim($v['cal']);
                            $s = str_replace(" ", ",", $aa);
                            $a1 = explode(",", $s);
                            foreach ($a1 as $k1 => $v1) {
                                if (in_array($v1, $arr)) {
                                    $n++;
                                }
                            }
                            if ($n > 1) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        //任选四
                        if ($v['m_type'] == '4') {
                            $au = trim(str_replace("+", ",", $resu['opencode']));
                            $arr = explode(",", $au);
                            $aa = rtrim($v['cal']);
                            $s = str_replace(" ", ",", $aa);
                            $a1 = explode(",", $s);
                            foreach ($a1 as $k1 => $v1) {
                                if (in_array($v1, $arr)) {
                                    $n++;
                                }
                            }
                            if ($n > 1) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        //任选五
                        if ($v['m_type'] == '5') {
                            $au = trim(str_replace("+", ",", $resu['opencode']));
                            $arr = explode(",", $au);
                            $aa = rtrim($v['cal']);
                            $s = str_replace(" ", ",", $aa);
                            $a1 = explode(",", $s);
                            foreach ($a1 as $k1 => $v1) {
                                if (in_array($v1, $arr)) {
                                    $n++;
                                }
                            }
                            if ($n > 2) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        //任选六
                        if ($v['m_type'] == '6') {
                            $au = trim(str_replace("+", ",", $resu['opencode']));
                            $arr = explode(",", $au);
                            $aa = rtrim($v['cal']);
                            $s = str_replace(" ", ",", $aa);
                            $a1 = explode(",", $s);
                            foreach ($a1 as $k1 => $v1) {
                                if (in_array($v1, $arr)) {
                                    $n++;
                                }
                            }
                            if ($n > 2) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        //任选七
                        if ($v['m_type'] == '7') {
                            $au = trim(str_replace("+", ",", $resu['opencode']));
                            $arr = explode(",", $au);
                            $aa = rtrim($v['cal']);
                            $s = str_replace(" ", ",", $aa);
                            $a1 = explode(",", $s);
                            foreach ($a1 as $k1 => $v1) {
                                if (in_array($v1, $arr)) {
                                    $n++;
                                }
                            }
                            if ($n > 3) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                    }
                    //趣味
                    if ($v['type'] == '2') {
                        //8上下盘9奇偶盘10和值大小单双
                        if ($v['m_type'] == '8') {
                            $aq = explode(",", $resu['qu_code']);
                            foreach ($aq as $kw => $vw) {
                                if ($vw < 41) {
                                    $u++;
                                }
                                if ($vw > 40) {
                                    $z++;
                                }
                            }
                            $ns = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            if ($u > $z) {
                                //上盘
                                if (in_array("上", $ns)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                            if ($u == $z) {
                                //中盘
                                if (in_array("中", $ns)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                            if ($u < $z) {
                                //下盘
                                if (in_array("下", $ns)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                        }
                        if ($v['m_type'] == '9') {
                            $aq1 = explode(",", $resu['qu_code']);
                            foreach ($aq1 as $kw1 => $vw1) {
                                if ($vw1 % 2 == 0) {
                                    $o++;
                                } else {
                                    $j++;
                                }
                            }
                            $ns = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            if ($o > $j) {
                                //偶盘
                                if (in_array("偶", $ns)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                            if ($o == $j) {
                                //和盘
                                if (in_array("和", $ns)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                            if ($o < $j) {
                                //奇盘
                                if (in_array("奇", $ns)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                        }
                        if ($v['m_type'] == '10') {
                            $aq2 = explode(",", $resu['qu_code']);
                            foreach ($aq2 as $kw2 => $vw2) {
                                $h += $vw2;
                            }
                            $ns1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            if ($h > 810) {
                                if ($h % 2 != 0) {
                                    //大单
                                    if (in_array("大单", $ns1)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                    }
                                }
                                if ($h % 2 == 0) {
                                    //大双
                                    if (in_array("大双", $ns1)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                    }
                                }
                            }
                            if ($h <= 810) {
                                if ($h % 2 != 0) {
                                    //小单
                                    if (in_array("小单", $ns1)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                    }
                                }
                                if ($h % 2 == 0) {
                                    //小双
                                    if (in_array("小双", $ns1)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                    }
                                }
                            }
                        }
                    }
                    $jieg[] = array($v['id'] => $resu['opencode']);
                }
            }
            foreach ($jieg as $kg => $vg) {
                foreach ($vg as $kt => $vt) {
                    $p[] = $kt;
                    $j1 = $vt;
                }
            }
            $pw = implode(",", $p);
            if ($pw) {
                M("zhui_kl8_detail")->where("id in($pw)")->save(array("opencode" => $j1));
            }
            foreach ($house55 as $k1 => $v1) {
                foreach ($arrl as $ka => $va) {
                    if (array_search(trim($v1['issue']), $va)) {
                        if (!in_array($v1['id'], $zid)) {
                            $wz[] = $v1['id'];
                        }
                        break;
                    }
                }
            }
            if (!empty($wz)) {
                $ccd = implode(",", $wz);
                //	M("zhui_kl8_detail")->where("id in($ccd)")->save(array("is_zhong"=>2));
            }
            if (!empty($zid)) {
                $zd = implode(",", $zid);
                M("zhui_kl8_detail")->where("id in($zd)")->save(array("is_zhong" => 1));
                $res = M("zhui_kl8_detail d")
                    ->join(" join " . C("DB_PREFIX") . "zhui_kl8 s on d.zhui_kl8_id=s.id")
                    ->where("d.id in($zd)")
                    ->field("d.id,d.zhui_kl8_id,d.zhong_money,s.uid,s.is_ting")
                    ->select();
                foreach ($res as $kz => $vz) {
                    $uu[] = $vz['uid'];
                }
                $uz = implode(",", $uu);
                if ($uz) {
                    $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                }
                foreach ($res as $kp1 => $vp1) {
                    foreach ($mo as $kp2 => $vp2) {
                        if ($vp1['uid'] == $vp2['userid']) {
                            $res[$kp1]['money'] = $vp2['money'];
                        }
                    }
                }
                foreach ($res as $kb => $vb) {
                    if ($vb['is_ting'] == '1') {
                        $p1[] = $vb['id'];
                    }
                    if ($vb['is_ting'] == '2') {
                        $p2[] = $vb['id'];
                    }
                }
                if ($p1) {
                    $zd = implode(",", $p1);
                    M("zhui_kl8_detail")->where("id in($zd)")->save(array("is_zhong" => 1));
                    $res1 = M("zhui_kl8_detail d")
                        ->join(" join " . C("DB_PREFIX") . "zhui_kl8 s on d.zhui_kl8_id=s.id")
                        ->where("d.id in($zd)")
                        ->field("d.zhui_kl8_id,d.zhong_money,s.uid")
                        ->select();
                    foreach ($res1 as $kz => $vz) {
                        $uu[] = $vz['uid'];
                    }
                    $uz = implode(",", $uu);
                    if ($uz) {
                        $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                    }
                    foreach ($res1 as $kp1 => $vp1) {
                        foreach ($mo as $kp2 => $vp2) {
                            if ($vp1['uid'] == $vp2['userid']) {
                                $res1[$kp1]['money'] = $vp2['money'];
                            }
                        }
                    }
                    foreach ($res1 as $kp => $vp) {
                        $zz[] = $vp['zhui_kl8_id'];
                        $uudd[] = $vp['uid'];
                        $history_date[] = array(
                            'number' => date("Ymd") . rand(100000, 999999),
                            'type' => '5',
                            'shou_money' => $vp['zhong_money'],
                            'ky_money' => $vp['money'],
                            'ctime' => time(),
                            'uid' => $vp['uid'],
                            'remark' => '奖金派送'
                        );
                    }
                    $lad = implode(",", $zz);
                    $udd = implode(",", $uudd);
                    $result = array();
                    foreach ($res1 as $ke1 => $info) {
                        if ($result[$info['zhui_kl8_id']]) {
                            $result[$info['zhui_kl8_id']] += $info['zhong_money'];
                        } else {
                            $result[$info['zhui_kl8_id']] = trim($info['zhong_money']);
                        }
                    }
                    $result1 = array();
                    foreach ($res1 as $ke2 => $info2) {
                        if ($result1[$info2['uid']]) {
                            $result1[$info2['uid']] += $info2['zhong_money'];
                        } else {
                            $result1[$info2['uid']] = trim($info2['zhong_money']);
                        }
                    }
                    foreach ($result1 as $kwi => $vwi) {
                        foreach ($mo as $k11 => $v11) {
                            if ($kwi == $v11['userid']) {
                                $result1[$kwi] = $vwi + $v11['money'];
                            }
                        }
                    }
                    $sq = "";
                    $sq1 = "";
                    foreach ($result as $ki => $vi) {
                        $sq .= " when id = {$ki} then '{$vi}' ";
                    }
                    foreach ($result1 as $ki1 => $vi1) {
                        $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                    }
                    $sql = "";
                    if (!empty($sq)) {
                        $sql .= ",zo_money = CASE {$sq} else zo_money end ";
                    }
                    $sql1 = "";
                    if (!empty($sq1)) {
                        $sql1 .= ",money = CASE {$sq1} else money end ";
                    }
                    if (!empty($sql)) {
                        $sql = trim($sql, ',');
                        $sql = "update " . C("DB_PREFIX") . "zhui_kl8 set {$sql}";
                        M()->execute($sql);
                    }
                    if (!empty($sql1)) {
                        $sql1 = trim($sql1, ',');
                        $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                        M()->execute($sql1);
                    }
                    M("jiaoyi")->addAll($history_date);
                    //停止追号
                    $ttt = M("zhui_kl8_detail xd")
                        ->join(" join " . C("DB_PREFIX") . "zhui_kl8 a on xd.zhui_kl8_id=a.id")
                        ->where("xd.zhui_kl8_id in($lad) and xd.is_zhong=0 ")
                        ->field("a.uid,xd.touzhu_money,xd.id")
                        ->select();
                    $result3 = array();
                    $isr = array();
                    $tyu = array();
                    foreach ($ttt as $ke3 => $info3) {
                        $isr[] = $info3['id'];
                        $tyu[] = $info3['uid'];
                        if ($result3[$info3['uid']]) {
                            $result3[$info3['uid']] += $info3['touzhu_money'];
                        } else {
                            $result3[$info3['uid']] = trim($info3['touzhu_money']);
                        }
                    }
                    $irs = implode(",", $isr);
                    $dfg = implode(",", $tyu);
                    if ($dfg) {
                        $yy1 = M('Accountsinfo')->where("userid in($dfg)")->select();
                    }

                    foreach ($yy1 as $kp1 => $vp1) {
                        $tui[] = array($vp1['userid'] => $vp1['money'] + $result3[$vp1['userid']]);
                        $history_date2[] = array(
                            'number' => date("Ymd") . rand(100000, 999999),
                            'type' => '8',
                            'shou_money' => $result3[$vp1['userid']],
                            'ky_money' => $vp1['money'],
                            'ctime' => time(),
                            'uid' => $vp1['userid'],
                            'remark' => '追号停止'
                        );
                    }
                    M("jiaoyi")->addAll($history_date2);
                    M("zhui_kl8_detail")->where("id in($irs) and is_zhong=0 ")->save(array("is_zhong" => 3, 'opencode' => "追号停止"));
                    $sq2 = "";
                    foreach ($tui as $ki2 => $vi2) {
                        foreach ($vi2 as $kkh => $vvh) {
                            $sq2 .= " when userid = {$kkh} then '{$vvh}' ";
                        }
                    }
                    $sql2 = "";
                    if (!empty($sq2)) {
                        $sql2 .= ",money = CASE {$sq2} else money end ";
                    }
                    if (!empty($sql2)) {
                        $sql2 = trim($sql2, ',');
                        $sql2 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql2}";
                        M()->execute($sql2);
                    }
                }
                if ($p2) {
                    $zd2 = implode(",", $p2);
                    M("zhui_kl8_detail")->where("id in($zd2)")->save(array("is_zhong" => 1));
                    $res1 = M("zhui_kl8_detail d")
                        ->join(" join " . C("DB_PREFIX") . "zhui_kl8 s on d.zhui_kl8_id=s.id")
                        ->where("d.id in($zd2)")
                        ->field("d.zhui_kl8_id,d.zhong_money,s.uid")
                        ->select();
                    foreach ($res1 as $kz => $vz) {
                        $uu[] = $vz['uid'];
                    }
                    $uz = implode(",", $uu);
                    if ($uz) {
                        $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                    }
                    foreach ($res1 as $kp1 => $vp1) {
                        foreach ($mo as $kp2 => $vp2) {
                            if ($vp1['uid'] == $vp2['userid']) {
                                $res1[$kp1]['money'] = $vp2['money'];
                            }
                        }
                    }
                    foreach ($res1 as $kp => $vp) {
                        $zz[] = $vp['zhui_kl8_id'];
                        $uudd[] = $vp['uid'];
                        $history_date3[] = array(
                            'number' => date("Ymd") . rand(100000, 999999),
                            'type' => '5',
                            'shou_money' => $vp['zhong_money'],
                            'ky_money' => $vp['money'],
                            'ctime' => time(),
                            'uid' => $vp['uid'],
                            'remark' => '奖金派送'
                        );
                    }
                    $lad = implode(",", $zz);
                    $udd = implode(",", $uudd);
                    $result = array();
                    foreach ($res1 as $ke1 => $info) {
                        if ($result[$info['zhui_kl8_id']]) {
                            $result[$info['zhui_kl8_id']] += $info['zhong_money'];
                        } else {
                            $result[$info['zhui_kl8_id']] = trim($info['zhong_money']);
                        }
                    }
                    $result1 = array();
                    foreach ($res1 as $ke2 => $info2) {
                        if ($result1[$info2['uid']]) {
                            $result1[$info2['uid']] += $info2['zhong_money'];
                        } else {
                            $result1[$info2['uid']] = trim($info2['zhong_money']);
                        }
                    }
                    foreach ($result1 as $kwi => $vwi) {
                        foreach ($mo as $k11 => $v11) {
                            if ($kwi == $v11['userid']) {
                                $result1[$kwi] = $vwi + $v11['money'];
                            }
                        }
                    }
                    $sq = "";
                    $sq1 = "";
                    foreach ($result as $ki => $vi) {
                        $sq .= " when id = {$ki} then '{$vi}' ";
                    }
                    foreach ($result1 as $ki1 => $vi1) {
                        $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                    }
                    $sql = "";
                    if (!empty($sq)) {
                        $sql .= ",zo_money = CASE {$sq} else zo_money end ";
                    }
                    $sql1 = "";
                    if (!empty($sq1)) {
                        $sql1 .= ",money = CASE {$sq1} else money end ";
                    }
                    if (!empty($sql)) {
                        $sql = trim($sql, ',');
                        $sql = "update " . C("DB_PREFIX") . "zhui_kl8 set {$sql}";
                        M()->execute($sql);
                    }
                    if (!empty($sql1)) {
                        $sql1 = trim($sql1, ',');
                        $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                        M()->execute($sql1);
                    }
                    M("jiaoyi")->addAll($history_date3);
                }
            }
        }
    }

    //追号pk10判断  1分钟1次
    public function zhui_cp()
    {
        $wz = array();

        $house313 = M("zhui_pk10_detail a")
            ->join(" join " . C("DB_PREFIX") . "zhui_pk10 b on a.zhui_pk10_id = b.id")
            ->field(array("a.*,b.id as bid,b.lotteryclass,b.is_ting"))
            ->where("a.is_zhong = 0")
            ->select();
        $ren_gong = M("ren_gong")->where("1=1")->select();
        if (!empty($house313)) {
            foreach ($house313 as $k => $v) {
                $resu = array();
                $qu = array();
                $arrbb = $this->get_data2("bjpk10");
                if (empty($arrbb)) {
                    $arrbb = $this->ren_gong($ren_gong, 21, $v['issue']);
                }
                foreach ($arrbb as $kc => $vc) {
                    $arrbb[$kc]['issue'] = trim($vc['issue']);
                }
                foreach ($arrbb as $ka => $va) {
                    if (array_search(trim($v['issue']), $va)) {
                        $resu = $arrbb[$ka];
                        break;
                    }
                }
                if (!empty($resu)) {
                    //定位胆
                    if ($v['type'] == '1') {
                        if ($v['m_type'] == '1') {
                            $aa = rtrim($v['cal']);
                            $ar1 = explode(",", $aa);
                            $ar2 = explode(",", $resu['opencode']);
                            for ($i = 0; $i < 10; $i++) {
                                if ($ar1[$i] === $ar2[$i]) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //猜前五
                    if ($v['type'] == '2') {
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr1 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr1[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr1[1]));
                            $a3 = explode(",", str_replace(" ", ",", $arr1[2]));
                            $a4 = explode(",", str_replace(" ", ",", $arr1[3]));
                            $a5 = explode(",", str_replace(" ", ",", $arr1[4]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    foreach ($a3 as $k3 => $v3) {
                                        foreach ($a4 as $k4 => $v4) {
                                            foreach ($a5 as $k5 => $v5) {
                                                if ($v1 != $v2 && $v2 != $v3 && $v3 != $v4 && $v4 != $v5 && $v3 != $v5) {
                                                    $qu[] = $v1 . ',' . $v2 . ',' . $v3 . ',' . $v4 . ',' . $v5;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 14) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $a1 = explode(",", rtrim($v['cal']));
                            foreach ($a1 as $k1 => $v1) {
                                if (substr($resu['opencode'], 0, 14) === str_replace(" ", ",", $v1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //猜前四
                    if ($v['type'] == '3') {
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr2 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr2[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr2[1]));
                            $a3 = explode(",", str_replace(" ", ",", $arr2[2]));
                            $a4 = explode(",", str_replace(" ", ",", $arr2[3]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    foreach ($a3 as $k3 => $v3) {
                                        foreach ($a4 as $k4 => $v4) {
                                            if ($v1 != $v2 && $v2 != $v3 && $v3 != $v4) {
                                                $qu[] = $v1 . ',' . $v2 . ',' . $v3 . ',' . $v4;
                                            }
                                        }
                                    }
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 11) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $a1 = explode(",", rtrim($v['cal']));
                            foreach ($a1 as $k1 => $v1) {
                                if (substr($resu['opencode'], 0, 11) === str_replace(" ", ",", $v1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //猜前三
                    if ($v['type'] == '4') {
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr3 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr3[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr3[1]));
                            $a3 = explode(",", str_replace(" ", ",", $arr3[2]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    foreach ($a3 as $k3 => $v3) {
                                        if ($v1 != $v2 && $v2 != $v3) {
                                            $qu[] = $v1 . ',' . $v2 . ',' . $v3;
                                        }
                                    }
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 8) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $a1 = explode(",", rtrim($v['cal']));
                            foreach ($a1 as $k1 => $v1) {
                                if (substr($resu['opencode'], 0, 8) === str_replace(" ", ",", $v1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //猜前二
                    if ($v['type'] == '5') {
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr4 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr4[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr4[1]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    if ($v1 != $v2) {
                                        $qu[] = $v1 . ',' . $v2;
                                    }
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 5) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $a1 = explode(",", rtrim($v['cal']));
                            foreach ($a1 as $k1 => $v1) {
                                if (substr($resu['opencode'], 0, 5) === str_replace(" ", ",", $v1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //猜冠军
                    if ($v['type'] == '6') {
                        $a = rtrim($v['cal']);
                        $a1 = explode(",", str_replace(" ", ",", $a));
                        foreach ($a1 as $k1 => $v1) {
                            if (substr($resu['opencode'], 0, 2) === $v1) {
                                //中奖
                                $zid[] = $v['id'];
                                break;
                            }
                        }
                    }
                    $jieg[] = array($v['id'] => $resu['opencode']);
                }
            }
            foreach ($jieg as $kg => $vg) {
                foreach ($vg as $kt => $vt) {
                    $p[] = $kt;
                    $j1 = $vt;
                }
            }
            $pw = implode(",", $p);
            if ($pw) {
                M("zhui_pk10_detail")->where("id in($pw)")->save(array("opencode" => $j1));
            }
            foreach ($house313 as $k1 => $v1) {
                foreach ($arrbb as $ka => $va) {
                    if (array_search(trim($v1['issue']), $va)) {
                        if (!in_array($v1['id'], $zid)) {
                            $wz[] = $v1['id'];
                        }
                        break;
                    }
                }
            }
            if (!empty($wz)) {
                $ccd = implode(",", $wz);
                //	M("zhui_pk10_detail")->where("id in($ccd)")->save(array("is_zhong"=>2));
            }
            if (!empty($zid)) {
                $zd = implode(",", $zid);
                M("zhui_pk10_detail")->where("id in($zd)")->save(array("is_zhong" => 1));
                $res = M("zhui_pk10_detail d")
                    ->join(" join " . C("DB_PREFIX") . "zhui_pk10 s on d.zhui_pk10_id=s.id")
                    ->where("d.id in($zd)")
                    ->field("d.id,d.zhui_pk10_id,d.zhong_money,s.uid,s.is_ting")
                    ->select();
                foreach ($res as $kz => $vz) {
                    $uu[] = $vz['uid'];
                }
                $uz = implode(",", $uu);
                if ($uz) {
                    $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                }
                foreach ($res as $kp1 => $vp1) {
                    foreach ($mo as $kp2 => $vp2) {
                        if ($vp1['uid'] == $vp2['userid']) {
                            $res[$kp1]['money'] = $vp2['money'];
                        }
                    }
                }
                foreach ($res as $kb => $vb) {
                    if ($vb['is_ting'] == '1') {
                        $p1[] = $vb['id'];
                    }
                    if ($vb['is_ting'] == '2') {
                        $p2[] = $vb['id'];
                    }
                }
                if ($p1) {
                    $zd = implode(",", $p1);
                    M("zhui_pk10_detail")->where("id in($zd)")->save(array("is_zhong" => 1));
                    $res1 = M("zhui_pk10_detail d")
                        ->join(" join " . C("DB_PREFIX") . "zhui_pk10 s on d.zhui_pk10_id=s.id")
                        ->where("d.id in($zd)")
                        ->field("d.zhui_pk10_id,d.zhong_money,s.uid")
                        ->select();
                    foreach ($res1 as $kz => $vz) {
                        $uu[] = $vz['uid'];
                    }
                    $uz = implode(",", $uu);
                    if ($uz) {
                        $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                    }
                    foreach ($res1 as $kp1 => $vp1) {
                        foreach ($mo as $kp2 => $vp2) {
                            if ($vp1['uid'] == $vp2['userid']) {
                                $res1[$kp1]['money'] = $vp2['money'];
                            }
                        }
                    }
                    foreach ($res1 as $kp => $vp) {
                        $zz[] = $vp['zhui_pk10_id'];
                        $uudd[] = $vp['uid'];
                        $history_date[] = array(
                            'number' => date("Ymd") . rand(100000, 999999),
                            'type' => '5',
                            'shou_money' => $vp['zhong_money'],
                            'ky_money' => $vp['money'],
                            'ctime' => time(),
                            'uid' => $vp['uid'],
                            'remark' => '奖金派送'
                        );
                    }
                    $lad = implode(",", $zz);
                    $udd = implode(",", $uudd);
                    $result = array();
                    foreach ($res1 as $ke1 => $info) {
                        if ($result[$info['zhui_pk10_id']]) {
                            $result[$info['zhui_pk10_id']] += $info['zhong_money'];
                        } else {
                            $result[$info['zhui_pk10_id']] = trim($info['zhong_money']);
                        }
                    }
                    $result1 = array();
                    foreach ($res1 as $ke2 => $info2) {
                        if ($result1[$info2['uid']]) {
                            $result1[$info2['uid']] += $info2['zhong_money'];
                        } else {
                            $result1[$info2['uid']] = trim($info2['zhong_money']);
                        }
                    }
                    foreach ($result1 as $kwi => $vwi) {
                        foreach ($mo as $k11 => $v11) {
                            if ($kwi == $v11['userid']) {
                                $result1[$kwi] = $vwi + $v11['money'];
                            }
                        }
                    }
                    $sq = "";
                    $sq1 = "";
                    foreach ($result as $ki => $vi) {
                        $sq .= " when id = {$ki} then '{$vi}' ";
                    }
                    foreach ($result1 as $ki1 => $vi1) {
                        $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                    }
                    $sql = "";
                    if (!empty($sq)) {
                        $sql .= ",zo_money = CASE {$sq} else zo_money end ";
                    }
                    $sql1 = "";
                    if (!empty($sq1)) {
                        $sql1 .= ",money = CASE {$sq1} else money end ";
                    }
                    if (!empty($sql)) {
                        $sql = trim($sql, ',');
                        $sql = "update " . C("DB_PREFIX") . "zhui_pk10 set {$sql}";
                        M()->execute($sql);
                    }
                    if (!empty($sql1)) {
                        $sql1 = trim($sql1, ',');
                        $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                        M()->execute($sql1);
                    }
                    M("jiaoyi")->addAll($history_date);
                    //停止追号
                    $ttt = M("zhui_pk10_detail xd")
                        ->join(" join " . C("DB_PREFIX") . "zhui_pk10 a on xd.zhui_pk10_id=a.id")
                        ->where("xd.zhui_pk10_id in($lad) and xd.is_zhong=0 ")
                        ->field("a.uid,xd.touzhu_money,xd.id")
                        ->select();
                    $result3 = array();
                    $isr = array();
                    $tyu = array();
                    foreach ($ttt as $ke3 => $info3) {
                        $isr[] = $info3['id'];
                        $tyu[] = $info3['uid'];
                        if ($result3[$info3['uid']]) {
                            $result3[$info3['uid']] += $info3['touzhu_money'];
                        } else {
                            $result3[$info3['uid']] = trim($info3['touzhu_money']);
                        }
                    }
                    $irs = implode(",", $isr);
                    $dfg = implode(",", $tyu);
                    if ($dfg) {
                        $yy1 = M('Accountsinfo')->where("userid in($dfg)")->select();
                    }

                    foreach ($yy1 as $kp1 => $vp1) {
                        $tui[] = array($vp1['userid'] => $vp1['money'] + $result3[$vp1['userid']]);
                        $history_date2[] = array(
                            'number' => date("Ymd") . rand(100000, 999999),
                            'type' => '8',
                            'shou_money' => $result3[$vp1['userid']],
                            'ky_money' => $vp1['money'],
                            'ctime' => time(),
                            'uid' => $vp1['userid'],
                            'remark' => '追号停止'
                        );
                    }
                    M("jiaoyi")->addAll($history_date2);
                    M("zhui_pk10_detail")->where("id in($irs) and is_zhong=0 ")->save(array("is_zhong" => 3, 'opencode' => "追号停止"));
                    $sq2 = "";
                    foreach ($tui as $ki2 => $vi2) {
                        foreach ($vi2 as $kkh => $vvh) {
                            $sq2 .= " when userid = {$kkh} then '{$vvh}' ";
                        }
                    }
                    $sql2 = "";
                    if (!empty($sq2)) {
                        $sql2 .= ",money = CASE {$sq2} else money end ";
                    }
                    if (!empty($sql2)) {
                        $sql2 = trim($sql2, ',');
                        $sql2 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql2}";
                        M()->execute($sql2);
                    }
                }
                if ($p2) {
                    $zd2 = implode(",", $p2);
                    M("zhui_pk10_detail")->where("id in($zd2)")->save(array("is_zhong" => 1));
                    $res1 = M("zhui_pk10_detail d")
                        ->join(" join " . C("DB_PREFIX") . "zhui_pk10 s on d.zhui_pk10_id=s.id")
                        ->where("d.id in($zd2)")
                        ->field("d.zhui_pk10_id,d.zhong_money,s.uid")
                        ->select();
                    foreach ($res1 as $kz => $vz) {
                        $uu[] = $vz['uid'];
                    }
                    $uz = implode(",", $uu);
                    if ($uz) {
                        $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                    }
                    foreach ($res1 as $kp1 => $vp1) {
                        foreach ($mo as $kp2 => $vp2) {
                            if ($vp1['uid'] == $vp2['userid']) {
                                $res1[$kp1]['money'] = $vp2['money'];
                            }
                        }
                    }
                    foreach ($res1 as $kp => $vp) {
                        $zz[] = $vp['zhui_pk10_id'];
                        $uudd[] = $vp['uid'];
                        $history_date3[] = array(
                            'number' => date("Ymd") . rand(100000, 999999),
                            'type' => '5',
                            'shou_money' => $vp['zhong_money'],
                            'ky_money' => $vp['money'],
                            'ctime' => time(),
                            'uid' => $vp['uid'],
                            'remark' => '奖金派送'
                        );
                    }
                    $lad = implode(",", $zz);
                    $udd = implode(",", $uudd);
                    $result = array();
                    foreach ($res1 as $ke1 => $info) {
                        if ($result[$info['zhui_pk10_id']]) {
                            $result[$info['zhui_pk10_id']] += $info['zhong_money'];
                        } else {
                            $result[$info['zhui_pk10_id']] = trim($info['zhong_money']);
                        }
                    }
                    $result1 = array();
                    foreach ($res1 as $ke2 => $info2) {
                        if ($result1[$info2['uid']]) {
                            $result1[$info2['uid']] += $info2['zhong_money'];
                        } else {
                            $result1[$info2['uid']] = trim($info2['zhong_money']);
                        }
                    }
                    foreach ($result1 as $kwi => $vwi) {
                        foreach ($mo as $k11 => $v11) {
                            if ($kwi == $v11['userid']) {
                                $result1[$kwi] = $vwi + $v11['money'];
                            }
                        }
                    }
                    $sq = "";
                    $sq1 = "";
                    foreach ($result as $ki => $vi) {
                        $sq .= " when id = {$ki} then '{$vi}' ";
                    }
                    foreach ($result1 as $ki1 => $vi1) {
                        $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                    }
                    $sql = "";
                    if (!empty($sq)) {
                        $sql .= ",zo_money = CASE {$sq} else zo_money end ";
                    }
                    $sql1 = "";
                    if (!empty($sq1)) {
                        $sql1 .= ",money = CASE {$sq1} else money end ";
                    }
                    if (!empty($sql)) {
                        $sql = trim($sql, ',');
                        $sql = "update " . C("DB_PREFIX") . "zhui_pk10 set {$sql}";
                        M()->execute($sql);
                    }
                    if (!empty($sql1)) {
                        $sql1 = trim($sql1, ',');
                        $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                        M()->execute($sql1);
                    }
                    M("jiaoyi")->addAll($history_date3);
                }
            }
        }
    }

    //判断投注中奖  1分钟1次
    public function zhongj()
    {
        //---------------判断快3中奖------------------------------------
        $house1 = M("lottery_add_detail a")
            ->join(" join " . C("DB_PREFIX") . "lottery_add b on a.lottery_add_id = b.id")
            ->field(array("a.*,b.uid,b.lotteryclass,b.issue,b.money,b.status"))
            ->where("a.is_zhong = 0 and b.status=0")
            ->select();
        $ren_gong = M("ren_gong")->where("1=1")->select();
        $jsk3 = $this->get_data("jsk3");
        $ahk3 = $this->get_data("ahk3");
        $gxk3 = $this->get_data("gxk3");
        $hubk3 = $this->get_data("hubk3");
        $bjk3 = $this->get_data("bjk3");
        $hebk3 = $this->get_data("hebk3");
        $gsk3 = $this->get_data("gsk3");
        $shk3 = $this->get_data("shk3");
        $gzk3 = $this->get_data("gzk3");
        $jlk3 = $this->get_data("jlk3");
        $wz = array();
        $zid = array();
        $jieg = array();
        $temp = array();
        if (!empty($house1)) {
            foreach ($house1 as $k => $v) {
                $resu = array();
                $arr = array();
                if ($v['lotteryclass'] == '1') {
                    $arr = $jsk3;
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 1, $v['issue']);
                        foreach ($arr as $km => $vm) {
                            $mom = explode(",", trim($vm['opencode']));
                            $m = 0;
                            foreach ($mom as $kc => $vc) {
                                $m += $vc;
                            }
                            $arr[$km]['total'] = $m;
                            if ($m >= 3 && $m <= 10) {
                                $arr[$km]['size'] = '1';//小
                            }
                            if ($m >= 11 && $m <= 18) {
                                $arr[$km]['size'] = '2';//大
                            }
                            if ($m % 2 != 0) {
                                $arr[$km]['attr'] = '1';//单
                            } else {
                                $arr[$km]['attr'] = '2';//双
                            }
                        }
                    }
                }
                if ($v['lotteryclass'] == '2') {
                    $arr = $ahk3;
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 2, $v['issue']);
                        foreach ($arr as $km => $vm) {
                            $mom = explode(",", trim($vm['opencode']));
                            $m = 0;
                            foreach ($mom as $kc => $vc) {
                                $m += $vc;
                            }
                            $arr[$km]['total'] = $m;
                            if ($m >= 3 && $m <= 10) {
                                $arr[$km]['size'] = '1';//小
                            }
                            if ($m >= 11 && $m <= 18) {
                                $arr[$km]['size'] = '2';//大
                            }
                            if ($m % 2 != 0) {
                                $arr[$km]['attr'] = '1';//单
                            } else {
                                $arr[$km]['attr'] = '2';//双
                            }
                        }
                    }
                }
                if ($v['lotteryclass'] == '3') {
                    $arr = $this->get_data("gxk3");
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 3, $v['issue']);
                        foreach ($arr as $km => $vm) {
                            $mom = explode(",", trim($vm['opencode']));
                            $m = 0;
                            foreach ($mom as $kc => $vc) {
                                $m += $vc;
                            }
                            $arr[$km]['total'] = $m;
                            if ($m >= 3 && $m <= 10) {
                                $arr[$km]['size'] = '1';//小
                            }
                            if ($m >= 11 && $m <= 18) {
                                $arr[$km]['size'] = '2';//大
                            }
                            if ($m % 2 != 0) {
                                $arr[$km]['attr'] = '1';//单
                            } else {
                                $arr[$km]['attr'] = '2';//双
                            }
                        }
                    }
                }
                if ($v['lotteryclass'] == '4') {
                    $arr = $hubk3;
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 4, $v['issue']);
                        foreach ($arr as $km => $vm) {
                            $mom = explode(",", trim($vm['opencode']));
                            $m = 0;
                            foreach ($mom as $kc => $vc) {
                                $m += $vc;
                            }
                            $arr[$km]['total'] = $m;
                            if ($m >= 3 && $m <= 10) {
                                $arr[$km]['size'] = '1';//小
                            }
                            if ($m >= 11 && $m <= 18) {
                                $arr[$km]['size'] = '2';//大
                            }
                            if ($m % 2 != 0) {
                                $arr[$km]['attr'] = '1';//单
                            } else {
                                $arr[$km]['attr'] = '2';//双
                            }
                        }
                    }
                }
                if ($v['lotteryclass'] == '5') {
                    $arr = $bjk3;
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 5, $v['issue']);
                        foreach ($arr as $km => $vm) {
                            $mom = explode(",", trim($vm['opencode']));
                            $m = 0;
                            foreach ($mom as $kc => $vc) {
                                $m += $vc;
                            }
                            $arr[$km]['total'] = $m;
                            if ($m >= 3 && $m <= 10) {
                                $arr[$km]['size'] = '1';//小
                            }
                            if ($m >= 11 && $m <= 18) {
                                $arr[$km]['size'] = '2';//大
                            }
                            if ($m % 2 != 0) {
                                $arr[$km]['attr'] = '1';//单
                            } else {
                                $arr[$km]['attr'] = '2';//双
                            }
                        }
                    }
                }
                if ($v['lotteryclass'] == '9') {
                    $arr = $hebk3;
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 9, $v['issue']);
                        foreach ($arr as $km => $vm) {
                            $mom = explode(",", trim($vm['opencode']));
                            $m = 0;
                            foreach ($mom as $kc => $vc) {
                                $m += $vc;
                            }
                            $arr[$km]['total'] = $m;
                            if ($m >= 3 && $m <= 10) {
                                $arr[$km]['size'] = '1';//小
                            }
                            if ($m >= 11 && $m <= 18) {
                                $arr[$km]['size'] = '2';//大
                            }
                            if ($m % 2 != 0) {
                                $arr[$km]['attr'] = '1';//单
                            } else {
                                $arr[$km]['attr'] = '2';//双
                            }
                        }
                    }
                }
                if ($v['lotteryclass'] == '10') {
                    $arr = $gsk3;
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 10, $v['issue']);
                        foreach ($arr as $km => $vm) {
                            $mom = explode(",", trim($vm['opencode']));
                            $m = 0;
                            foreach ($mom as $kc => $vc) {
                                $m += $vc;
                            }
                            $arr[$km]['total'] = $m;
                            if ($m >= 3 && $m <= 10) {
                                $arr[$km]['size'] = '1';//小
                            }
                            if ($m >= 11 && $m <= 18) {
                                $arr[$km]['size'] = '2';//大
                            }
                            if ($m % 2 != 0) {
                                $arr[$km]['attr'] = '1';//单
                            } else {
                                $arr[$km]['attr'] = '2';//双
                            }
                        }
                    }
                }
                if ($v['lotteryclass'] == '11') {
                    $arr = $shk3;
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 11, $v['issue']);
                        foreach ($arr as $km => $vm) {
                            $mom = explode(",", trim($vm['opencode']));
                            $m = 0;
                            foreach ($mom as $kc => $vc) {
                                $m += $vc;
                            }
                            $arr[$km]['total'] = $m;
                            if ($m >= 3 && $m <= 10) {
                                $arr[$km]['size'] = '1';//小
                            }
                            if ($m >= 11 && $m <= 18) {
                                $arr[$km]['size'] = '2';//大
                            }
                            if ($m % 2 != 0) {
                                $arr[$km]['attr'] = '1';//单
                            } else {
                                $arr[$km]['attr'] = '2';//双
                            }
                        }
                    }
                }
                if ($v['lotteryclass'] == '12') {
                    $arr = $gzk3;
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 12, $v['issue']);
                        foreach ($arr as $km => $vm) {
                            $mom = explode(",", trim($vm['opencode']));
                            $m = 0;
                            foreach ($mom as $kc => $vc) {
                                $m += $vc;
                            }
                            $arr[$km]['total'] = $m;
                            if ($m >= 3 && $m <= 10) {
                                $arr[$km]['size'] = '1';//小
                            }
                            if ($m >= 11 && $m <= 18) {
                                $arr[$km]['size'] = '2';//大
                            }
                            if ($m % 2 != 0) {
                                $arr[$km]['attr'] = '1';//单
                            } else {
                                $arr[$km]['attr'] = '2';//双
                            }
                        }
                    }
                }
                if ($v['lotteryclass'] == '13') {
                    $arr = $jlk3;
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 13, $v['issue']);
                        foreach ($arr as $km => $vm) {
                            $mom = explode(",", trim($vm['opencode']));
                            $m = 0;
                            foreach ($mom as $kc => $vc) {
                                $m += $vc;
                            }
                            $arr[$km]['total'] = $m;
                            if ($m >= 3 && $m <= 10) {
                                $arr[$km]['size'] = '1';//小
                            }
                            if ($m >= 11 && $m <= 18) {
                                $arr[$km]['size'] = '2';//大
                            }
                            if ($m % 2 != 0) {
                                $arr[$km]['attr'] = '1';//单
                            } else {
                                $arr[$km]['attr'] = '2';//双
                            }
                        }
                    }
                }
                foreach ($arr as $ka => $va) {
                    if (array_search(trim($v['issue']), $va)) {
                        $resu = $arr[$ka];
                        break;
                    }
                }
                if (!empty($resu)) {
                    //和值
                    if ($v['type'] == '1') {
                        if (is_numeric(trim($v['cal']))) {
                            if (trim($v['cal']) == $resu['total']) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        } else {
                            $cra = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            if (in_array('单', $cra)) {
                                if ($resu['attr'] == '1') {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                            if (in_array('双', $cra)) {
                                if ($resu['attr'] == '2') {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                            if (in_array('大', $cra)) {
                                if ($resu['size'] == '2') {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                            if (in_array('小', $cra)) {
                                if ($resu['size'] == '1') {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                        }
                    }
                    //三同号通选
                    if ($v['type'] == '2') {
                        $ar = array('111', '222', '333', '444', '555', '666');
                        $au = trim(str_replace(",", "", $resu['opencode']));
                        if (in_array($au, $ar)) {
                            //中奖
                            $zid[] = $v['id'];
                        }
                    }
                    //三同号单选
                    if ($v['type'] == '3') {
                        $ry = explode(",", $v['cal']);
                        $au = trim(str_replace(",", "", $resu['opencode']));
                        if (in_array($au, $ry)) {
                            //中奖
                            $zid[] = $v['id'];
                        }
                    }
                    //三不同号
                    if ($v['type'] == '4') {
                        $yt = explode(",", $resu['opencode']);
                        if ($yt['0'] != $yt['1'] && $yt['1'] != $yt['2'] && $yt['0'] != $yt['2']) {
                            //三个号码 各不相同
                            $aaa = rtrim($v['cal']);
                            $va = str_replace(" ", ",", $aaa);
                            $sr = explode(",", $va);
                            $t = getCombinationToString($sr, 3);
                            foreach ($t as $ka => $va) {
                                $as = str_replace(",", "", $va);
                                $t[$ka] = $as;
                            }
                            $ass = str_replace(",", "", $resu['opencode']);
                            if (in_array($ass, $t)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                    }
                    //三连号通选
                    if ($v['type'] == '5') {
                        $ar = array('123', '234', '345', '456');
                        $au = trim(str_replace(",", "", $resu['opencode']));
                        if (in_array($au, $ar)) {
                            //中奖
                            $zid[] = $v['id'];
                        }
                    }
                    //二同号复选
                    if ($v['type'] == '6') {
                        $yt = explode(",", $resu['opencode']);
                        if ($yt['0'] == $yt['1'] && $yt['1'] == $yt['2']) {
                            //三个数字都相同
                        } else {
                            if ($yt['0'] == $yt['1'] || $yt['1'] == $yt['2'] || $yt['0'] == $yt['2']) {
                                //有两个号码相同  不包括 豹子
                                $aaa = rtrim($v['cal']);
                                $va = str_replace(" ", ",", $aaa);
                                $sr = explode(",", $va);//11 22 33 44

                                $ab = explode(",", $resu['opencode']);

                                if ($ab[0] == $ab[1]) {
                                    $str = $ab[0] . $ab[1];
                                }
                                if ($ab[1] == $ab[2]) {
                                    $str = $ab[1] . $ab[2];
                                }
                                if ($ab[0] == $ab[2]) {
                                    $str = $ab[0] . $ab[2];
                                }
                                if (in_array($str, $sr)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                        }
                    }
                    //二同号单选
                    if ($v['type'] == '7') {
                        $bbb = rtrim($v['cal']);
                        $ac = explode(",", $bbb);
                        $v1 = str_replace(" ", ",", $ac[0]);
                        $av = explode(",", $v1);
                        foreach ($av as $ka => $va) {
                            $s = substr($va, 0, 1);
                            $s1 = $s . ',';
                            $av[$ka] = $s1 . $s;
                        }
                        $v6 = str_replace(" ", ",", $ac[1]);
                        $ae = explode(",", $v6);
                        foreach ($av as $kq => $vq) {
                            foreach ($ae as $kw => $vw) {
                                $aq[] = $vq . ',' . $vw;
                            }
                        }
                        if (in_array($resu['opencode'], $aq)) {
                            //中奖
                            $zid[] = $v['id'];
                        }
                    }
                    //二不同号
                    if ($v['type'] == '8') {
                        $aa1 = rtrim($v['cal']);
                        $v1 = str_replace(" ", ",", $aa1);

                        $arra = explode(",", $v1);
                        $ay = explode(",", $resu['opencode']);
                        if (in_array($ay[0], $arra)) {
                            if (in_array($ay[1], $arra) || in_array($ay[2], $arra)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if (in_array($ay[1], $arra)) {
                            if (in_array($ay[0], $arra) || in_array($ay[2], $arra)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if (in_array($ay[2], $arra)) {
                            if (in_array($ay[0], $arra) || in_array($ay[1], $arra)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        $zid = array_unique($zid);
                    }
                    $jieg[] = array($v['lottery_add_id'] => $resu['opencode']);
                }
            }
            foreach ($jieg as $kg => $vg) {
                foreach ($vg as $kt => $vt) {
                    if (!in_array($kt, $temp)) {
                        $temp[$kt] = $vt;
                    }
                }
            }
            $sq = "";
            foreach ($temp as $ki => $vi) {
                $sq .= " when id = {$ki} then '{$vi}' ";
            }
            $sql = "";
            if (!empty($sq)) {
                $sql .= ",opencode = CASE {$sq} else opencode end ";
            }
            if (!empty($sql)) {
                $sql = trim($sql, ',');
                $sql = "update " . C("DB_PREFIX") . "lottery_add set {$sql}";
                M()->execute($sql);
            }
            foreach ($house1 as $k1 => $v1) {
                foreach ($arr as $ka => $va) {
                    if (array_search(trim($v1['issue']), $va)) {
                        if (!in_array($v1['id'], $zid)) {
                            $wz[] = $v1['id'];
                        }
                        break;
                    }
                }
            }
            if (!empty($wz)) {
                $ccd = implode(",", $wz);
                M("lottery_add_detail")->where("id in($ccd)")->save(array("is_zhong" => 2));
            }
            //0925改到这
            if (!empty($zid)) {
                $zd = implode(",", $zid);
                M("lottery_add_detail")->where("id in($zd)")->save(array("is_zhong" => 1));
                $res = M("lottery_add_detail d")
                    ->join(" join " . C("DB_PREFIX") . "lottery_add s on d.lottery_add_id=s.id")
                    ->where("d.id in($zd)")
                    ->field("d.lottery_add_id,d.con_money,s.uid")
                    ->select();
                foreach ($res as $kz => $vz) {
                    $uu[] = $vz['uid'];
                }
                $uz = implode(",", $uu);
                if ($uz) {
                    $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                }
                foreach ($res as $kp1 => $vp1) {
                    foreach ($mo as $kp2 => $vp2) {
                        if ($vp1['uid'] == $vp2['userid']) {
                            $res[$kp1]['money'] = $vp2['money'];
                        }
                    }
                }
                $total = 0;
                foreach ($res as $kp => $vp) {
                    $zz[] = $vp['lottery_add_id'];
                    $uudd[] = $vp['uid'];
                    $total += $vp['con_money'];
                    $history_date[] = array(
                        'number' => date("Ymd") . rand(100000, 999999),
                        'type' => '5',
                        'shou_money' => $vp['con_money'],
                        'ky_money' => $vp['money'],
                        'ctime' => time(),
                        'uid' => $vp['uid'],
                        'remark' => '奖金派送'
                    );
                }
                $result = array();
                foreach ($res as $ke1 => $info) {
                    if ($result[$info['lottery_add_id']]) {

                        $result[$info['lottery_add_id']] += $info['con_money'];
                    } else {
                        $result[$info['lottery_add_id']] = trim($info['con_money']);
                    }
                }
                $result1 = array();
                foreach ($res as $ke2 => $info2) {
                    if ($result1[$info2['uid']]) {
                        $result1[$info2['uid']] += $info2['con_money'];
                    } else {
                        $result1[$info2['uid']] = trim($info2['con_money']);
                    }
                }
                foreach ($result1 as $kwi => $vwi) {
                    foreach ($mo as $k11 => $v11) {
                        if ($kwi == $v11['userid']) {
                            $result1[$kwi] = $vwi + $v11['money'];
                        }
                    }
                }
                $sq = "";
                $sq1 = "";
                foreach ($result as $ki => $vi) {
                    $sq .= " when id = {$ki} then '{$vi}' ";
                }
                foreach ($result1 as $ki1 => $vi1) {
                    $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                }
                $sql = "";
                if (!empty($sq)) {
                    $sql .= ",zong_money = CASE {$sq} else zong_money end ";
                }
                $sql1 = "";
                if (!empty($sq1)) {
                    $sql1 .= ",money = CASE {$sq1} else money end ";
                }
                if (!empty($sql)) {
                    $sql = trim($sql, ',');
                    $sql = "update " . C("DB_PREFIX") . "lottery_add set {$sql}";
                    M()->execute($sql);
                }
                if (!empty($sql1)) {
                    $sql1 = trim($sql1, ',');
                    $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                    M()->execute($sql1);
                }
                M("jiaoyi")->addAll($history_date);
            }
        }
        $wz = array();
        $zid = array();
        $jieg = array();
        $temp = array();
        //---------------判断快乐8中奖----------------------------------
        $house = M("lottery_kl8_detail a")
            ->join(" join " . C("DB_PREFIX") . "lottery_kl8 b on a.lottery_kl8_id = b.id")
            ->field(array("a.*,b.uid,b.issue,b.money,b.status"))
            ->where("a.is_zhong = 0 and b.status=0")
            ->select();
        if (!empty($house)) {
            foreach ($house as $k => $v) {
                $arr8 = $this->get_data2("bjkl8");
                if (empty($arr8)) {
                    $arr8 = $this->ren_gong($ren_gong, 20, $v['issue']);
                }
                foreach ($arr8 as $kc => $vc) {
                    $arr8[$kc]['issue'] = trim($vc['issue']);
                    $co = substr($vc['opencode'], 0, 59);
                    $arr8[$kc]['qu_code'] = $co;
                }
                $resu = array();
                $n = 0;
                $u = 0;
                $z = 0;
                $o = 0;
                $j = 0;
                $h = 0;
                foreach ($arr8 as $ka => $va) {
                    if (array_search(trim($v['issue']), $va)) {
                        $resu = $arr8[$ka];
                        break;
                    }
                }
                if (!empty($resu)) {
                    //任选
                    if ($v['type'] == '1') {
                        //任选一
                        if ($v['m_type'] == '1') {
                            $au = trim(str_replace("+", ",", $resu['opencode']));
                            $arr = explode(",", $au);
                            $aa = rtrim($v['cal']);
                            $s = str_replace(" ", ",", $aa);
                            $a1 = explode(",", $s);
                            foreach ($a1 as $k1 => $v1) {
                                if (in_array($v1, $arr)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        //任选二
                        if ($v['m_type'] == '2') {
                            $au = trim(str_replace("+", ",", $resu['opencode']));
                            $arr = explode(",", $au);
                            $aa = rtrim($v['cal']);
                            $s = str_replace(" ", ",", $aa);
                            $a1 = explode(",", $s);
                            foreach ($a1 as $k1 => $v1) {
                                if (in_array($v1, $arr)) {
                                    $n++;
                                }
                            }
                            if ($n > 1) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        //任选三
                        if ($v['m_type'] == '3') {
                            $au = trim(str_replace("+", ",", $resu['opencode']));
                            $arr = explode(",", $au);
                            $aa = rtrim($v['cal']);
                            $s = str_replace(" ", ",", $aa);
                            $a1 = explode(",", $s);
                            foreach ($a1 as $k1 => $v1) {
                                if (in_array($v1, $arr)) {
                                    $n++;
                                }
                            }
                            if ($n > 1) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        //任选四
                        if ($v['m_type'] == '4') {
                            $au = trim(str_replace("+", ",", $resu['opencode']));
                            $arr = explode(",", $au);
                            $aa = rtrim($v['cal']);
                            $s = str_replace(" ", ",", $aa);
                            $a1 = explode(",", $s);
                            foreach ($a1 as $k1 => $v1) {
                                if (in_array($v1, $arr)) {
                                    $n++;
                                }
                            }
                            if ($n > 1) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        //任选五
                        if ($v['m_type'] == '5') {
                            $au = trim(str_replace("+", ",", $resu['opencode']));
                            $arr = explode(",", $au);
                            $aa = rtrim($v['cal']);
                            $s = str_replace(" ", ",", $aa);
                            $a1 = explode(",", $s);
                            foreach ($a1 as $k1 => $v1) {
                                if (in_array($v1, $arr)) {
                                    $n++;
                                }
                            }
                            if ($n > 2) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        //任选六
                        if ($v['m_type'] == '6') {
                            $au = trim(str_replace("+", ",", $resu['opencode']));
                            $arr = explode(",", $au);
                            $aa = rtrim($v['cal']);
                            $s = str_replace(" ", ",", $aa);
                            $a1 = explode(",", $s);
                            foreach ($a1 as $k1 => $v1) {
                                if (in_array($v1, $arr)) {
                                    $n++;
                                }
                            }
                            if ($n > 2) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        //任选七
                        if ($v['m_type'] == '7') {
                            $au = trim(str_replace("+", ",", $resu['opencode']));
                            $arr = explode(",", $au);
                            $aa = rtrim($v['cal']);
                            $s = str_replace(" ", ",", $aa);
                            $a1 = explode(",", $s);
                            foreach ($a1 as $k1 => $v1) {
                                if (in_array($v1, $arr)) {
                                    $n++;
                                }
                            }
                            if ($n > 3) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                    }
                    //趣味
                    if ($v['type'] == '2') {
                        //8上下盘9奇偶盘10和值大小单双
                        if ($v['m_type'] == '8') {
                            $aq = explode(",", $resu['qu_code']);
                            foreach ($aq as $kw => $vw) {
                                if ($vw < 41) {
                                    $u++;
                                }
                                if ($vw > 40) {
                                    $z++;
                                }
                            }
                            $ns = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            if ($u > $z) {
                                //上盘
                                if (in_array("上", $ns)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                            if ($u == $z) {
                                //中盘
                                if (in_array("中", $ns)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                            if ($u < $z) {
                                //下盘
                                if (in_array("下", $ns)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                        }
                        if ($v['m_type'] == '9') {
                            $aq1 = explode(",", $resu['qu_code']);
                            foreach ($aq1 as $kw1 => $vw1) {
                                if ($vw1 % 2 == 0) {
                                    $o++;
                                } else {
                                    $j++;
                                }
                            }
                            $ns = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            if ($o > $j) {
                                //偶盘
                                if (in_array("偶", $ns)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                            if ($o == $j) {
                                //和盘
                                if (in_array("和", $ns)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                            if ($o < $j) {
                                //奇盘
                                if (in_array("奇", $ns)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                        }
                        if ($v['m_type'] == '10') {
                            $aq2 = explode(",", $resu['qu_code']);
                            foreach ($aq2 as $kw2 => $vw2) {
                                $h += $vw2;
                            }
                            $ns1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            if ($h > 810) {
                                if ($h % 2 != 0) {
                                    //大单
                                    if (in_array("大单", $ns1)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                    }
                                }
                                if ($h % 2 == 0) {
                                    //大双
                                    if (in_array("大双", $ns1)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                    }
                                }
                            }
                            if ($h <= 810) {
                                if ($h % 2 != 0) {
                                    //小单
                                    if (in_array("小单", $ns1)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                    }
                                }
                                if ($h % 2 == 0) {
                                    //小双
                                    if (in_array("小双", $ns1)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                    }
                                }
                            }
                        }
                    }
                    $jieg[] = array($v['lottery_kl8_id'] => $resu['opencode']);
                }
            }
            $sq = "";
            foreach ($jieg as $ki => $vi) {
                foreach ($vi as $kj => $vj) {
                    $sq .= " when id = {$kj} then '{$vj}' ";
                }
            }
            $sql = "";
            if (!empty($sq)) {
                $sql .= ",opencode = CASE {$sq} else opencode end ";
            }
            if (!empty($sql)) {
                $sql = trim($sql, ',');
                $sql = "update " . C("DB_PREFIX") . "lottery_kl8 set {$sql}";
                M()->execute($sql);
            }
            foreach ($house as $k2 => $v2) {
                foreach ($arr8 as $ka => $va) {
                    if (array_search(trim($v2['issue']), $va)) {
                        if (!in_array($v2['id'], $zid)) {
                            $wz[] = $v2['id'];
                        }
                        break;
                    }
                }
            }
            if (!empty($wz)) {
                $ccd = implode(",", $wz);
                M("lottery_kl8_detail")->where("id in($ccd)")->save(array("is_zhong" => 2));
            }
            if (!empty($zid)) {
                $zd = implode(",", $zid);
                M("lottery_kl8_detail")->where("id in($zd)")->save(array("is_zhong" => 1));

                $res = M("lottery_kl8_detail d")
                    ->join(" join " . C("DB_PREFIX") . "lottery_kl8 s on d.lottery_kl8_id=s.id")
                    ->where("d.id in($zd)")
                    ->field("d.lottery_kl8_id,d.zo_money,s.uid")
                    ->select();
                foreach ($res as $kz => $vz) {
                    $uu[] = $vz['uid'];
                }
                $uz = implode(",", $uu);
                if ($uz) {
                    $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                }
                foreach ($res as $kp1 => $vp1) {
                    foreach ($mo as $kp2 => $vp2) {
                        if ($vp1['uid'] == $vp2['userid']) {
                            $res[$kp1]['money'] = $vp2['money'];
                        }
                    }
                }
                $total = 0;
                foreach ($res as $kp => $vp) {
                    $zz[] = $vp['lottery_kl8_id'];
                    $uudd[] = $vp['uid'];
                    $total += $vp['zo_money'];
                    $history_date1[] = array(
                        'number' => date("Ymd") . rand(100000, 999999),
                        'type' => '5',
                        'shou_money' => $vp['zo_money'],
                        'ky_money' => $vp['money'],
                        'ctime' => time(),
                        'uid' => $vp['uid'],
                        'remark' => '奖金派送'
                    );
                }
                $result = array();
                foreach ($res as $ke1 => $info) {
                    if ($result[$info['lottery_kl8_id']]) {
                        $result[$info['lottery_kl8_id']] += $info['zo_money'];
                    } else {
                        $result[$info['lottery_kl8_id']] = trim($info['zo_money']);
                    }
                }
                $result1 = array();
                foreach ($res as $ke2 => $info2) {
                    if ($result1[$info2['uid']]) {
                        $result1[$info2['uid']] += $info2['zo_money'];
                    } else {
                        $result1[$info2['uid']] = trim($info2['zo_money']);
                    }
                }
                foreach ($result1 as $kwii => $vwii) {
                    foreach ($mo as $k11 => $v11) {
                        if ($kwii == $v11['userid']) {
                            $result1[$kwii] = $vwii + $v11['money'];
                        }
                    }
                }
                $sq = "";
                $sq1 = "";
                foreach ($result as $ki => $vi) {
                    $sq .= " when id = {$ki} then '{$vi}' ";
                }
                foreach ($result1 as $ki1 => $vi1) {
                    $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                }
                $sql = "";
                if (!empty($sq)) {
                    $sql .= ",zong_money = CASE {$sq} else zong_money end ";
                }
                $sql1 = "";
                if (!empty($sq1)) {
                    $sql1 .= ",money = CASE {$sq1} else money end ";
                }
                if (!empty($sql)) {
                    $sql = trim($sql, ',');
                    $sql = "update " . C("DB_PREFIX") . "lottery_kl8 set {$sql}";
                    M()->execute($sql);
                }
                if (!empty($sql1)) {
                    $sql1 = trim($sql1, ',');
                    $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                    M()->execute($sql1);
                }
                M("jiaoyi")->addAll($history_date1);
            }
        }
        $wz = array();
        $zid = array();
        $jieg = array();
        $temp = array();
        //-------------------北京PK10---------------------------------
        $house3 = M("lottery_pk10_detail a")
            ->join(" join " . C("DB_PREFIX") . "lottery_pk10 b on a.lottery_pk10_id = b.id")
            ->field(array("a.*,b.uid,b.issue,b.status"))
            ->where("a.is_zhong = 0 and b.status = 0")
            ->select();
        if (!empty($house3)) {
            foreach ($house3 as $k => $v) {
                $resu = array();
                $qu = array();
                $arrb = $this->get_data2("bjpk10");
                if (empty($arrb)) {
                    $arrb = $this->ren_gong($ren_gong, 21, $v['issue']);
                }
                foreach ($arrb as $ka => $va) {
                    if (array_search(trim($v['issue']), $va)) {
                        $resu = $arrb[$ka];
                        break;
                    }
                }
                if (!empty($resu)) {
                    //定位胆
                    if ($v['type'] == '1') {
                        if ($v['m_type'] == '1') {
                            $aa = rtrim($v['cal']);
                            $ar1 = explode(",", $aa);
                            $ar2 = explode(",", $resu['opencode']);
                            for ($i = 0; $i < 10; $i++) {
                                if ($ar1[$i] === $ar2[$i]) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //猜前五
                    if ($v['type'] == '2') {
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr1 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr1[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr1[1]));
                            $a3 = explode(",", str_replace(" ", ",", $arr1[2]));
                            $a4 = explode(",", str_replace(" ", ",", $arr1[3]));
                            $a5 = explode(",", str_replace(" ", ",", $arr1[4]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    foreach ($a3 as $k3 => $v3) {
                                        foreach ($a4 as $k4 => $v4) {
                                            foreach ($a5 as $k5 => $v5) {
                                                if ($v1 != $v2 && $v2 != $v3 && $v3 != $v4 && $v4 != $v5 && $v3 != $v5) {
                                                    $qu[] = $v1 . ',' . $v2 . ',' . $v3 . ',' . $v4 . ',' . $v5;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 14) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $a1 = explode(",", rtrim($v['cal']));
                            foreach ($a1 as $k1 => $v1) {
                                if (substr($resu['opencode'], 0, 14) === str_replace(" ", ",", $v1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //猜前四
                    if ($v['type'] == '3') {
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr2 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr2[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr2[1]));
                            $a3 = explode(",", str_replace(" ", ",", $arr2[2]));
                            $a4 = explode(",", str_replace(" ", ",", $arr2[3]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    foreach ($a3 as $k3 => $v3) {
                                        foreach ($a4 as $k4 => $v4) {
                                            if ($v1 != $v2 && $v2 != $v3 && $v3 != $v4) {
                                                $qu[] = $v1 . ',' . $v2 . ',' . $v3 . ',' . $v4;
                                            }
                                        }
                                    }
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 11) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $a1 = explode(",", rtrim($v['cal']));
                            foreach ($a1 as $k1 => $v1) {
                                if (substr($resu['opencode'], 0, 11) === str_replace(" ", ",", $v1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //猜前三
                    if ($v['type'] == '4') {
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr3 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr3[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr3[1]));
                            $a3 = explode(",", str_replace(" ", ",", $arr3[2]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    foreach ($a3 as $k3 => $v3) {
                                        if ($v1 != $v2 && $v2 != $v3) {
                                            $qu[] = $v1 . ',' . $v2 . ',' . $v3;
                                        }
                                    }
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 8) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $a1 = explode(",", rtrim($v['cal']));
                            foreach ($a1 as $k1 => $v1) {
                                if (substr($resu['opencode'], 0, 8) === str_replace(" ", ",", $v1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //猜前二
                    if ($v['type'] == '5') {
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr4 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr4[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr4[1]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    if ($v1 != $v2) {
                                        $qu[] = $v1 . ',' . $v2;
                                    }
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 5) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $a1 = explode(",", rtrim($v['cal']));
                            foreach ($a1 as $k1 => $v1) {
                                if (substr($resu['opencode'], 0, 5) === str_replace(" ", ",", $v1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //猜冠军
                    if ($v['type'] == '6') {
                        $a = rtrim($v['cal']);
                        $a1 = explode(",", str_replace(" ", ",", $a));
                        foreach ($a1 as $k1 => $v1) {
                            if (substr($resu['opencode'], 0, 2) === $v1) {
                                //中奖
                                $zid[] = $v['id'];
                                break;
                            }
                        }
                    }
                    $jieg[] = array($v['lottery_pk10_id'] => $resu['opencode']);
                }
            }
            $sq = "";
            foreach ($jieg as $kg => $vg) {
                foreach ($vg as $kt => $vt) {
                    $sq .= " when id = {$kt} then '{$vt}' ";
                }
            }
            $sql = "";
            if (!empty($sq)) {
                $sql .= ",opencode = CASE {$sq} else opencode end ";
            }
            if (!empty($sql)) {
                $sql = trim($sql, ',');
                $sql = "update " . C("DB_PREFIX") . "lottery_pk10 set {$sql}";
                M()->execute($sql);
            }
            foreach ($house3 as $k3 => $v3) {
                foreach ($arrb as $ka => $va) {
                    if (array_search(trim($v3['issue']), $va)) {
                        if (!in_array($v3['id'], $zid)) {
                            $wz[] = $v3['id'];
                        }
                        break;
                    }
                }
            }
            if (!empty($wz)) {
                $ccd = implode(",", $wz);
                M("lottery_pk10_detail")->where("id in($ccd)")->save(array("is_zhong" => 2));
            }
            if (!empty($zid)) {
                $zd = implode(",", $zid);
                M("lottery_pk10_detail")->where("id in($zd)")->save(array("is_zhong" => 1));
                $res = M("lottery_pk10_detail d")
                    ->join(" join " . C("DB_PREFIX") . "lottery_pk10 s on d.lottery_pk10_id=s.id")
                    ->where("d.id in($zd)")
                    ->field("d.lottery_pk10_id,d.zo_money,s.uid")
                    ->select();
                foreach ($res as $kz => $vz) {
                    $uu[] = $vz['uid'];
                }
                $uz = implode(",", $uu);
                if ($uz) {
                    $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                }
                foreach ($res as $kp1 => $vp1) {
                    foreach ($mo as $kp2 => $vp2) {
                        if ($vp1['uid'] == $vp2['userid']) {
                            $res[$kp1]['money'] = $vp2['money'];
                        }
                    }
                }
                $total = 0;
                foreach ($res as $kp => $vp) {
                    $zz[] = $vp['lottery_pk10_id'];
                    $uudd[] = $vp['uid'];
                    $total += $vp['zo_money'];
                    $history_date2[] = array(
                        'number' => date("Ymd") . rand(100000, 999999),
                        'type' => '5',
                        'shou_money' => $vp['zo_money'],
                        'ky_money' => $vp['money'],
                        'ctime' => time(),
                        'uid' => $vp['uid'],
                        'remark' => '奖金派送'
                    );
                }
                $result = array();
                foreach ($res as $ke1 => $info) {
                    if ($result[$info['lottery_pk10_id']]) {
                        $result[$info['lottery_pk10_id']] += $info['zo_money'];
                    } else {
                        $result[$info['lottery_pk10_id']] = trim($info['zo_money']);
                    }
                }
                $result1 = array();
                foreach ($res as $ke2 => $info2) {
                    if ($result1[$info2['uid']]) {
                        $result1[$info2['uid']] += $info2['zo_money'];
                    } else {
                        $result1[$info2['uid']] = trim($info2['zo_money']);
                    }
                }
                foreach ($result1 as $kwi => $vwi) {
                    foreach ($mo as $k11 => $v11) {
                        if ($kwi == $v11['userid']) {
                            $result1[$kwi] = $vwi + $v11['money'];
                        }
                    }
                }
                $sq = "";
                $sq1 = "";
                foreach ($result as $ki => $vi) {
                    $sq .= " when id = {$ki} then '{$vi}' ";
                }
                foreach ($result1 as $ki1 => $vi1) {
                    $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                }
                $sql = "";
                if (!empty($sq)) {
                    $sql .= ",zong_money = CASE {$sq} else zong_money end ";
                }
                $sql1 = "";
                if (!empty($sq1)) {
                    $sql1 .= ",money = CASE {$sq1} else money end ";
                }
                if (!empty($sql)) {
                    $sql = trim($sql, ',');
                    $sql = "update " . C("DB_PREFIX") . "lottery_pk10 set {$sql}";
                    M()->execute($sql);
                }
                if (!empty($sql1)) {
                    $sql1 = trim($sql1, ',');
                    $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                    M()->execute($sql1);
                }
                M("jiaoyi")->addAll($history_date2);
            }
        }
        $wz = array();
        $zid = array();
        $jieg = array();
        $temp = array();
        //------------------低频彩---------------------------------------
        $house5 = M("lottery_fc3d_detail a")
            ->join(" join " . C("DB_PREFIX") . "lottery_fc3d b on a.lottery_fc3d_id = b.id")
            ->field(array("a.*,b.uid,b.issue,b.money,b.lotteryclass,b.status"))
            ->where("a.is_zhong = 0 and b.status = 0")
            ->select();
        if (!empty($house5)) {
            foreach ($house5 as $k => $v) {
                $resu = array();
                $arr = array();
                $qu = array();
                $n = 0;
                $str = array();
                $s = array();
                if ($v['lotteryclass'] == '26') {
                    $arr = $this->get_data2("fc3d");
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 26, $v['issue']);
                    }
                }
                if ($v['lotteryclass'] == '27') {
                    $arr = $this->get_data("pl3");
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 27, $v['issue']);
                    }
                }
                foreach ($arr as $ka => $va) {
                    if (array_search(trim($v['issue']), $va)) {
                        $resu = $arr[$ka];
                        break;
                    }
                }
                if (!empty($resu)) {
                    //三星
                    if ($v['type'] == '1') {
                        //复式
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr1 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr1[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr1[1]));
                            $a3 = explode(",", str_replace(" ", ",", $arr1[2]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    foreach ($a3 as $k3 => $v3) {
                                        $qu[] = $v1 . ',' . $v2 . ',' . $v3;
                                    }
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if ($resu['opencode'] === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        //单式
                        if ($v['m_type'] == '2') {
                            $c1 = str_replace(",", "", $resu['opencode']);
                            $q = explode(",", rtrim($v["cal"]));
                            foreach ($q as $kk => $v3) {
                                if ($c1 === $v3) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        //和值
                        if ($v['m_type'] == '3') {
                            $a = rtrim($v['cal']);
                            $arr1 = explode(",", $resu['opencode']);
                            $au = explode(",", str_replace(" ", ",", $a));
                            foreach ($arr1 as $kk => $vv) {
                                $n += $vv;
                            }
                            if (in_array($n, $au)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        //跨度
                        if ($v['m_type'] == '4') {
                            $a1 = explode(",", $resu['opencode']);
                            sort($a1);
                            $min = $a1[0];
                            $max = end($a1);
                            $c1 = $max - $min;
                            $a = rtrim($v['cal']);
                            $au = explode(",", str_replace(" ", ",", $a));
                            if (in_array($c1, $au)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        //组选和值
                        if ($v['m_type'] == '5') {
                            $a1 = explode(",", $resu['opencode']);
                            if ($a1[0] == $a1[1] && $a1[1] == $a1[2]) {

                            } else {
                                $a = rtrim($v['cal']);
                                $arr1 = explode(",", $resu['opencode']);
                                $au = explode(",", str_replace(" ", ",", $a));
                                foreach ($arr1 as $kk => $vv) {
                                    $n += $vv;
                                }
                                if (in_array($n, $au)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                        }
                        //组三
                        if ($v['m_type'] == '6') {
                            $eq = str_replace(" ", ",", rtrim($v['cal']));
                            $ee = $eq . ',' . $eq;
                            $ar = explode(",", $ee);
                            $ne = getCombinationToString($ar, 3);
                            $nar = array();
                            foreach ($ne as $kk => $vv) {
                                if (!in_array($vv, $nar)) {
                                    $a = explode(",", $vv);
                                    if ($a[0] == $a[1] || $a[1] == $a[2]) {
                                        $re = str_replace(",", "", $vv);
                                        $nar[] = $re;
                                    }
                                }
                            }
                            $oc = explode(",", $resu['opencode']);
                            sort($oc);
                            $rs = str_replace(",", "", implode(",", $oc));
                            if (in_array($rs, $nar)) {
                                $zid[] = $v['id'];
                            }
                        }
                        //组六
                        if ($v['m_type'] == '7') {
                            $q = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ay = getCombinationToString($q, 3);
                            foreach ($ay as $kk => $vv) {
                                if ($resu['opencode'] === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        //混合组选      组三单式   组六单式
                        if ($v['m_type'] == '8' || $v['m_type'] == '10' || $v['m_type'] == '11') {
                            $cc = explode(",", $$resu['opencode']);
                            sort($cc);
                            $nc = implode(",", $cc);
                            $nnc = str_replace(",", "", $nc);

                            $q = explode(",", rtrim($v['cal']));
                            $news = array();
                            foreach ($q as $kk => $vv) {
                                $news[] = substr_cut($vv);
                            }
                            $aa = array();
                            foreach ($news as $kq => $vq) {
                                $aa[] = implode(",", $vq);
                            }
                            foreach ($aa as $ke => $ve) {
                                $aa[$ke] = str_replace(",", "", $ve);
                                if ($nnc === $aa[$ke]) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        //组选包胆
                        if ($v['m_type'] == '9') {
                            $cc = trim($v['cal']);
                            $a = explode(",", $resu['opencode']);
                            if ($a[0] != $a[1] || $a[1] != $a[2]) {
                                if (in_array($cc, $a)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        //一码不定位
                        if ($v['m_type'] == '12') {
                            $q = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $a = explode(",", $resu['opencode']);
                            foreach ($q as $kk => $vv) {
                                if (in_array($vv, $a)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        //二码不定位
                        if ($v['m_type'] == '13') {
                            $w = explode(",", $resu['opencode']);
                            $q = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ay = getCombinationToString($q, 2);
                            $ay1 = getCombinationToString($w, 2);
                            foreach ($ay1 as $kk => $vv) {
                                foreach ($ay as $ka => $va) {
                                    if ($vv === $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    //前二
                    if ($v['type'] == '2') {
                        //直选复式
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr1 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr1[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr1[1]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    $qu[] = $v1 . ',' . $v2;
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 3) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $cc = str_replace(",", "", $resu['opencode']);
                            $a = rtrim($v['cal']);
                            $arr1 = explode(",", $a);
                            foreach ($arr1 as $kk => $vv) {
                                if (substr($cc, 0, 2) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $q = explode(",", $resu['opencode']);
                            $he = $q[0] + $q[1];
                            $a = str_replace(" ", ",", rtrim($v['cal']));
                            $arr1 = explode(",", $a);
                            foreach ($arr1 as $kk => $vv) {
                                if ($he == $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ha = substr($resu['opencode'], 0, 3);
                            $a1 = explode(",", $ha);
                            sort($a1);
                            $min = $a1[0];
                            $max = end($a1);
                            $c1 = $max - $min;
                            $a = rtrim($v['cal']);
                            $au = explode(",", str_replace(" ", ",", $a));
                            if (in_array($c1, $au)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            $ree = implode(",", $op);
                            $nar = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $an = getCombinationToString($nar, 2);
                            foreach ($an as $ka => $va) {
                                if (substr($ree, 0, 3) === $va) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            $ass = $op[0] . $op[1];
                            $nar = explode(",", rtrim($v['cal']));
                            foreach ($nar as $ka => $va) {
                                if ($ass === $va) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $op = explode(",", $resu['opencode']);
                            if ($op[0] != $op[1]) {
                                $ass = $op[0] + $op[1];
                                $nar = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                foreach ($nar as $ka => $va) {
                                    if ($ass == $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $nc = trim($v['cal']);
                            $op = explode(",", $resu['opencode']);
                            if ($op[0] == $nc || $op[1] == $nc) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                    }
                    //后二
                    if ($v['type'] == '3') {
                        //直选复式
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr1 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr1[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr1[1]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    $qu[] = $v1 . ',' . $v2;
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 2) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $cc = str_replace(",", "", $resu['opencode']);
                            $a = rtrim($v['cal']);
                            $arr1 = explode(",", $a);
                            foreach ($arr1 as $kk => $vv) {
                                if (substr($cc, 2) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $q = explode(",", $resu['opencode']);
                            $he = $q[1] + $q[2];
                            $a = str_replace(" ", ",", rtrim($v['cal']));
                            $arr1 = explode(",", $a);
                            foreach ($arr1 as $kk => $vv) {
                                if ($he == $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ha = substr($resu['opencode'], 2);
                            $a1 = explode(",", $ha);
                            sort($a1);
                            $min = $a1[0];
                            $max = end($a1);
                            $c1 = $max - $min;
                            $a = rtrim($v['cal']);
                            $au = explode(",", str_replace(" ", ",", $a));
                            if (in_array($c1, $au)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            $ree = implode(",", $op);
                            $nar = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $an = getCombinationToString($nar, 2);
                            foreach ($an as $ka => $va) {
                                if (substr($ree, 2) === $va) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            $ass = $op[1] . $op[2];
                            $nar = explode(",", rtrim($v['cal']));
                            foreach ($nar as $ka => $va) {
                                if ($ass === $va) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $op = explode(",", $resu['opencode']);
                            if ($op[1] != $op[2]) {
                                $ass = $op[1] + $op[2];
                                $nar = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                foreach ($nar as $ka => $va) {
                                    if ($ass == $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $nc = trim($v['cal']);
                            $op = explode(",", $resu['opencode']);
                            if ($op[1] == $nc || $op[2] == $nc) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                    }
                    //一星
                    if ($v['type'] == '4') {
                        if ($v['m_type'] == '1') {
                            $bai = substr($resu['opencode'], 0, 1);
                            $shi = substr($resu['opencode'], 2, 1);
                            $ge = substr($resu['opencode'], 4, 1);
                            $aa = rtrim($v['cal']);
                            $ar = explode(",", $aa);
                            if (!empty($ar[0])) {
                                $b = explode(",", str_replace(" ", ",", $ar[0]));
                                if (in_array($bai, $b)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                            if (!empty($ar[1])) {
                                $b1 = explode(",", str_replace(" ", ",", $ar[1]));
                                if (in_array($shi, $b1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                            if (!empty($ar[2])) {
                                $b2 = explode(",", str_replace(" ", ",", $ar[2]));
                                if (in_array($ge, $b2)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                        }
                        $zid = array_unique($zid);
                    }
                    //
                    if ($v['type'] == '5') {
                        if ($v['m_type'] == '1') {
                            $n = explode(",", rtrim($v['cal']));
                            $qian = explode(",", str_replace(" ", ",", $n[0]));
                            $hou = explode(",", str_replace(" ", ",", $n[1]));
                            $arr = explode(",", $resu['opencode']);
                            if ($arr[0] >= 0 && $arr[0] <= 4) {
                                $str[] = "小";
                            }
                            if ($arr[0] >= 5 && $arr[0] <= 9) {
                                $str[] = "大";
                            }
                            if ($arr[0] % 2 == 0) {
                                $str[] = "双";
                            } else {
                                $str[] = "单";
                            }
                            if ($arr[1] >= 0 && $arr[1] <= 4) {
                                $s[] = "小";
                            }
                            if ($arr[1] >= 5 && $arr[1] <= 9) {
                                $s[] = "大";
                            }
                            if ($arr[1] % 2 == 0) {
                                $s[] = "双";
                            } else {
                                $s[] = "单";
                            }
                            foreach ($qian as $ka => $va) {
                                if (in_array($va, $str)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            foreach ($hou as $ka1 => $va1) {
                                if (in_array($va1, $s)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            $zid = array_unique($zid);
                        }
                        if ($v['m_type'] == '2') {
                            $n = explode(",", rtrim($v['cal']));
                            $qian = explode(",", str_replace(" ", ",", $n[0]));
                            $hou = explode(",", str_replace(" ", ",", $n[1]));
                            $arr = explode(",", $resu['opencode']);
                            if ($arr[1] >= 0 && $arr[1] <= 4) {
                                $str[] = "小";
                            }
                            if ($arr[1] >= 5 && $arr[1] <= 9) {
                                $str[] = "大";
                            }
                            if ($arr[1] % 2 == 0) {
                                $str[] = "双";
                            } else {
                                $str[] = "单";
                            }
                            if ($arr[2] >= 0 && $arr[2] <= 4) {
                                $s[] = "小";
                            }
                            if ($arr[2] >= 5 && $arr[2] <= 9) {
                                $s[] = "大";
                            }
                            if ($arr[2] % 2 == 0) {
                                $s[] = "双";
                            } else {
                                $s[] = "单";
                            }
                            foreach ($qian as $ka => $va) {
                                if (in_array($va, $str)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            foreach ($hou as $ka1 => $va1) {
                                if (in_array($va1, $s)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        $zid = array_unique($zid);
                    }
                    $jieg[] = array($v['lottery_fc3d_id'] => $resu['opencode']);
                }
            }
            foreach ($jieg as $kg => $vg) {
                foreach ($vg as $kt => $vt) {
                    if (!in_array($kt, $temp)) {
                        $temp[$kt] = $vt;
                    }
                }
            }
            $sq = "";
            foreach ($temp as $ki => $vi) {
                $sq .= " when id = {$ki} then '{$vi}' ";
            }
            $sql = "";
            if (!empty($sq)) {
                $sql .= ",opencode = CASE {$sq} else opencode end ";
            }
            if (!empty($sql)) {
                $sql = trim($sql, ',');
                $sql = "update " . C("DB_PREFIX") . "lottery_fc3d set {$sql}";
                M()->execute($sql);
            }
            foreach ($house5 as $k5 => $v5) {
                foreach ($arr as $ka => $va) {
                    if (array_search(trim($v5['issue']), $va)) {
                        if (!in_array($v5['id'], $zid)) {
                            $wz[] = $v5['id'];
                        }
                        break;
                    }
                }
            }
            if (!empty($wz)) {
                $ccd = implode(",", $wz);
                M("lottery_fc3d_detail")->where("id in($ccd)")->save(array("is_zhong" => 2));
            }
            if (!empty($zid)) {
                $zd = implode(",", $zid);
                M("lottery_fc3d_detail")->where("id in($zd)")->save(array("is_zhong" => 1));

                $res = M("lottery_fc3d_detail d")
                    ->join(" join " . C("DB_PREFIX") . "lottery_fc3d s on d.lottery_fc3d_id=s.id")
                    ->where("d.id in($zd)")
                    ->field("d.lottery_fc3d_id,d.zo_money,s.uid")
                    ->select();
                foreach ($res as $kz => $vz) {
                    $uu[] = $vz['uid'];
                }
                $uz = implode(",", $uu);
                if ($uz) {
                    $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                }
                foreach ($res as $kp1 => $vp1) {
                    foreach ($mo as $kp2 => $vp2) {
                        if ($vp1['uid'] == $vp2['userid']) {
                            $res[$kp1]['money'] = $vp2['money'];
                        }
                    }
                }
                $total = 0;
                foreach ($res as $kp => $vp) {
                    $zz[] = $vp['lottery_fc3d_id'];
                    $uudd[] = $vp['uid'];
                    $total += $vp['zo_money'];
                    $history_date4[] = array(
                        'number' => date("Ymd") . rand(100000, 999999),
                        'type' => '5',
                        'shou_money' => $vp['zo_money'],
                        'ky_money' => $vp['money'],
                        'ctime' => time(),
                        'uid' => $vp['uid'],
                        'remark' => '奖金派送'
                    );
                }
                $result = array();
                foreach ($res as $ke1 => $info) {
                    if ($result[$info['lottery_fc3d_id']]) {
                        $result[$info['lottery_fc3d_id']] += $info['zo_money'];
                    } else {
                        $result[$info['lottery_fc3d_id']] = trim($info['zo_money']);
                    }
                }
                $result1 = array();
                foreach ($res as $ke2 => $info2) {
                    if ($result1[$info2['uid']]) {
                        $result1[$info2['uid']] += $info2['zo_money'];
                    } else {
                        $result1[$info2['uid']] = trim($info2['zo_money']);
                    }
                }
                foreach ($result1 as $kwi => $vwi) {
                    foreach ($mo as $k11 => $v11) {
                        if ($kwi == $v11['userid']) {
                            $result1[$kwi] = $vwi + $v11['money'];
                        }
                    }
                }
                $sq = "";
                $sq1 = "";
                foreach ($result as $ki => $vi) {
                    $sq .= " when id = {$ki} then '{$vi}' ";
                }
                foreach ($result1 as $ki1 => $vi1) {
                    $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                }
                $sql = "";
                if (!empty($sq)) {
                    $sql .= ",zong_money = CASE {$sq} else zong_money end ";
                }
                $sql1 = "";
                if (!empty($sq1)) {
                    $sql1 .= ",money = CASE {$sq1} else money end ";
                }
                if (!empty($sql)) {
                    $sql = trim($sql, ',');
                    $sql = "update " . C("DB_PREFIX") . "lottery_fc3d set {$sql}";
                    M()->execute($sql);
                }
                if (!empty($sql1)) {
                    $sql1 = trim($sql1, ',');
                    $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                    M()->execute($sql1);
                }
                M("jiaoyi")->addAll($history_date4);
            }
        }
        $wz = array();
        $zid = array();
        $jieg = array();
        $temp = array();
        //------------------11选5------------------------------------------
        $house6 = M("lottery_11x5_detail a")
            ->join(" join " . C("DB_PREFIX") . "lottery_11x5 b on a.lottery_11x5_id = b.id")
            ->field(array("a.*,b.uid,b.issue,b.money,b.lotteryclass,b.status"))
            ->where("a.is_zhong = 0 and b.status=0")
            ->select();
        if (!empty($house6)) {
            foreach ($house6 as $k => $v) {
                $resu = array();
                $arr = array();
                $qu = array();
                $a = 0;
                $b = 0;
                $ne = array();
                $n = 0;
                if ($v['lotteryclass'] == '22') {
                    $arr = $this->get_data2("gd11x5");
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 22, $v['issue']);
                    }
                }
                if ($v['lotteryclass'] == '23') {
                    $arr = $this->get_data("sh11x5");
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 23, $v['issue']);
                    }
                }
                if ($v['lotteryclass'] == '24') {
                    $arr = $this->get_data2("sd11x5");
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 24, $v['issue']);
                    }
                }
                if ($v['lotteryclass'] == '25') {
                    $arr = $this->get_data("jx11x5");
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 25, $v['issue']);
                    }
                }
                foreach ($arr as $ka => $va) {
                    if (array_search(trim($v['issue']), $va)) {
                        $resu = $arr[$ka];
                        break;
                    }
                }
                if (!empty($resu)) {
                    //三码
                    if ($v['type'] == '1') {
                        if ($v['m_type'] == '1') {
                            $arr1 = explode(",", rtrim($v['cal']));
                            $a1 = explode(",", str_replace(" ", ",", $arr1[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr1[1]));
                            $a3 = explode(",", str_replace(" ", ",", $arr1[2]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    foreach ($a3 as $k3 => $v3) {
                                        if ($v1 != $v2 && $v2 != $v3 && $v1 != $v3) {
                                            $qu[] = $v1 . ',' . $v2 . ',' . $v3;
                                        }
                                    }
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 8) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $arr1 = explode(",", str_replace(" ", "", rtrim($v['cal'])));
                            $c1 = str_replace(",", "", $resu['opencode']);
                            foreach ($arr1 as $kk => $vv) {
                                if ($c1 === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ne = getCombinationToString($ar, 3);
                            $nr = explode(",", $resu['opencode']);
                            sort($nr);
                            $qe = implode(",", $nr);
                            foreach ($ne as $kk => $vv) {
                                if ($qe === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar = explode(",", rtrim($v['cal']));
                            foreach ($ar as $kk => $vv) {
                                $ts = explode(" ", $vv);
                                sort($ts);
                                $ar[$kk] = str_replace(" ", "", implode(" ", $ts));
                            }
                            $nr = explode(",", $resu['opencode']);
                            sort($nr);
                            $qe = str_replace(",", "", implode(",", $nr));
                            foreach ($ar as $kk1 => $vv1) {
                                if ($qe === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        //前三组选胆拖
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", $v['cal']);
                            $pa = explode(",", str_replace(" ", ",", $ar1[0]));
                            if (count($pa) == '1') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 3);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    if (in_array($ar1[0], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '2') {
                                $cc = explode(",", rtrim($v['cal']));
                                $ty = str_replace(" ", ",", $cc[0]);
                                $rq = explode(",", str_replace(" ", ",", $cc[1]));
                                foreach ($rq as $k => $v) {
                                    $ne[] = $ty . ',' . $v;
                                }
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", substr($resu['opencode'], 0, 8));
                            sort($op);
                            $nstr = implode(",", $op);
                            if (in_array($nstr, $ne)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                    }
                    //二码
                    if ($v['type'] == '2') {
                        if ($v['m_type'] == '1') {
                            $arr1 = explode(",", rtrim($v['cal']));
                            $a1 = explode(",", str_replace(" ", ",", $arr1[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr1[1]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    if ($v1 != $v2) {
                                        $qu[] = $v1 . ',' . $v2;
                                    }
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 5) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $arr1 = explode(",", rtrim($v['cal']));
                            foreach ($arr1 as $kk => $vv) {
                                if (str_replace(" ", ",", $vv) === substr($resu['opencode'], 0, 5)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ne = getCombinationToString($ar, 2);
                            $nr = explode(",", $resu['opencode']);
                            sort($nr);
                            $qe = implode(",", $nr);
                            foreach ($ne as $kk => $vv) {
                                if (substr($qe, 0, 5) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar = explode(",", rtrim($v['cal']));
                            foreach ($ar as $kk => $vv) {
                                $ts = explode(" ", $vv);
                                sort($ts);
                                $ar[$kk] = str_replace(" ", "", implode(" ", $ts));
                            }
                            $nr = explode(",", $resu['opencode']);
                            sort($nr);
                            $qe = str_replace(",", "", implode(",", $nr));
                            foreach ($ar as $kk1 => $vv1) {
                                if (substr($qe, 0, 4) === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        //前二组选胆拖
                        if ($v['m_type'] == '5') {
                            $cc = explode(",", rtrim($v['cal']));
                            $ty = str_replace(" ", ",", $cc[0]);
                            $rq = explode(",", str_replace(" ", ",", $cc[1]));
                            foreach ($rq as $k => $v) {
                                $ne[] = $ty . ',' . $v;
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", substr($resu['opencode'], 0, 5));
                            sort($op);
                            $nstr = implode(",", $op);
                            if (in_array($nstr, $ne)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                    }
                    //不定位
                    if ($v['type'] == '3') {
                        if ($v['m_type'] == '1') {
                            $ar = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            if (in_array(substr($resu['opencode'], 0, 2), $ar)) {
                                $zid[] = $v['id'];
                            }
                            if (in_array(substr($resu['opencode'], 3, 2), $ar)) {
                                $zid[] = $v['id'];
                            }
                            if (in_array(substr($resu['opencode'], 6, 2), $ar)) {
                                $zid[] = $v['id'];
                            }
                            $zid = array_unique($zid);
                        }
                    }
                    //定位胆
                    if ($v['type'] == '4') {
                        if ($v['m_type'] == '1') {
                            $aa = rtrim($v['cal']);
                            $ar1 = explode(",", $aa);
                            $ar2 = explode(",", substr($resu['opencode'], 0, 8));
                            for ($i = 0; $i < 3; $i++) {
                                if ($ar1[$i] === $ar2[$i]) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //趣味性
                    if ($v['type'] == '5') {
                        if ($v['m_type'] == '1') {
                            $qd = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = explode(",", $resu['opencode']);
                            foreach ($ar2 as $ka => $va) {
                                if ($va % 2 == 0) {
                                    $a++;
                                } else {
                                    $b++;
                                }
                            }
                            $str = $b . "单" . $a . "双";
                            if (in_array($str, $qd)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $qd = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = explode(",", $resu['opencode']);
                            sort($ar2);
                            if (in_array($ar2['2'], $qd)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                    }
                    //任选复式
                    if ($v['type'] == '6') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $ka => $va) {
                                if (in_array($va, $op)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nas = getCombinationToString($ar1, 2);
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($nas as $kk => $vv) {
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nas = getCombinationToString($ar1, 3);
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($nas as $kk => $vv) {
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        if (in_array($ab[2], $op)) {
                                            //中奖
                                            $zid[] = $v['id'];
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nas = getCombinationToString($ar1, 4);
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($nas as $kk => $vv) {
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        if (in_array($ab[2], $op)) {
                                            if (in_array($ab[3], $op)) {
                                                //中奖
                                                $zid[] = $v['id'];
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nas = getCombinationToString($ar1, 5);
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($nas as $kk => $vv) {
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        if (in_array($ab[2], $op)) {
                                            if (in_array($ab[3], $op)) {
                                                if (in_array($ab[4], $op)) {
                                                    //中奖
                                                    $zid[] = $v['id'];
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nas = getCombinationToString($ar1, 6);
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($nas as $kk => $vv) {
                                $n = 0;
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if ($n >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nas = getCombinationToString($ar1, 7);
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($nas as $kk => $vv) {
                                $n = 0;
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[6], $op)) {
                                    $u++;
                                }
                                if ($n >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nas = getCombinationToString($ar1, 8);
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($nas as $kk => $vv) {
                                $n = 0;
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[6], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[7], $op)) {
                                    $u++;
                                }
                                if ($n >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //任选单式
                    if ($v['type'] == '7') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                if (in_array($vv, $op)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                $ab = explode(",", str_replace(" ", ",", $vv));
                                sort($ab);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                $ab = explode(",", str_replace(" ", ",", $vv));
                                sort($ab);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        if (in_array($ab[2], $op)) {
                                            //中奖
                                            $zid[] = $v['id'];
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                $ab = explode(",", str_replace(" ", ",", $vv));
                                sort($ab);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        if (in_array($ab[2], $op)) {
                                            if (in_array($ab[3], $op)) {
                                                //中奖
                                                $zid[] = $v['id'];
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                $ab = explode(",", str_replace(" ", ",", $vv));
                                sort($ab);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        if (in_array($ab[2], $op)) {
                                            if (in_array($ab[3], $op)) {
                                                if (in_array($ab[4], $op)) {
                                                    //中奖
                                                    $zid[] = $v['id'];
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                $u = 0;
                                $ab = explode(",", str_replace(" ", ",", $vv));
                                sort($ab);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if ($u >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                $u = 0;
                                $ab = explode(",", str_replace(" ", ",", $vv));
                                sort($ab);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[6], $op)) {
                                    $u++;
                                }
                                if ($u >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            foreach ($ar1 as $kk => $vv) {
                                $u = 0;
                                $ab = explode(",", str_replace(" ", ",", $vv));
                                sort($ab);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[6], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[7], $op)) {
                                    $u++;
                                }
                                if ($u >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    //任选胆拖
                    if ($v['type'] == '8') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $op = explode(",", $resu['opencode']);
                            $na = explode(",", str_replace(" ", ",", $ar1[1]));
                            $cp = array();
                            foreach ($na as $ka => $va) {
                                $cp[] = $ar1[0] . "," . $va;
                            }
                            foreach ($cp as $kk => $vv) {
                                $rt = explode(",", $vv);
                                sort($rt);
                                $cp[$kk] = implode(",", $rt);
                            }
                            sort($op);
                            foreach ($cp as $kq => $vq) {
                                $u = 0;
                                $ab = explode(",", $vq);
                                if (in_array($ab[0], $op)) {
                                    if (in_array($ab[1], $op)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", $v['cal']);
                            $pa = explode(",", str_replace(" ", ",", $ar1[0]));
                            if (count($pa) == '1') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 3);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    if (in_array($ar1[0], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '2') {
                                $cc = explode(",", rtrim($v['cal']));
                                $ty = str_replace(" ", ",", $cc[0]);
                                $rq = explode(",", str_replace(" ", ",", $cc[1]));
                                foreach ($rq as $k => $v) {
                                    $ne[] = $ty . ',' . $v;
                                }
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", substr($resu['opencode'], 0, 8));
                            sort($op);
                            $nstr = implode(",", $op);
                            if (in_array($nstr, $ne)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", $v['cal']);
                            $pa = explode(",", str_replace(" ", ",", $ar1[0]));
                            if (count($pa) == '1') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 4);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    if (in_array($ar1[0], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '2') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 4);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else {
                                $cc = explode(",", rtrim($v['cal']));
                                $ty = str_replace(" ", ",", $cc[0]);
                                $rq = explode(",", str_replace(" ", ",", $cc[1]));
                                foreach ($rq as $k => $v) {
                                    $ne[] = $ty . ',' . $v;
                                }
                                foreach ($ne as $k1 => $v1) {
                                    $ts = explode(",", $v1);
                                    sort($ts);
                                    $ne[$k1] = implode(",", $ts);
                                }
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            $nstr = implode(",", $op);
                            $ss = substr($nstr, 0, 11);
                            if (in_array($ss, $ne)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", $v['cal']);
                            $pa = explode(",", str_replace(" ", ",", $ar1[0]));
                            if (count($pa) == '1') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 5);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    if (in_array($ar1[0], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '2') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 5);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '3') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 5);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else {
                                $cc = explode(",", rtrim($v['cal']));
                                $ty = str_replace(" ", ",", $cc[0]);
                                $rq = explode(",", str_replace(" ", ",", $cc[1]));
                                foreach ($rq as $k => $v) {
                                    $ne[] = $ty . ',' . $v;
                                }
                                foreach ($ne as $k1 => $v1) {
                                    $ts = explode(",", $v1);
                                    sort($ts);
                                    $ne[$k1] = implode(",", $ts);
                                }
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            $nstr = implode(",", $op);
                            if (in_array($nstr, $ne)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", $v['cal']);
                            $pa = explode(",", str_replace(" ", ",", $ar1[0]));
                            if (count($pa) == '1') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 6);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    if (in_array($ar1[0], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '2') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 6);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '3') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 6);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '4') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 6);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr) && in_array($ae[3], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else {
                                $cc = explode(",", rtrim($v['cal']));
                                $ty = str_replace(" ", ",", $cc[0]);
                                $rq = explode(",", str_replace(" ", ",", $cc[1]));
                                foreach ($rq as $k => $v) {
                                    $ne[] = $ty . ',' . $v;
                                }
                                foreach ($ne as $k1 => $v1) {
                                    $ts = explode(",", $v1);
                                    sort($ts);
                                    $ne[$k1] = implode(",", $ts);
                                }
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            $nstr = implode(",", $op);
                            foreach ($ne as $kk => $vv) {
                                $u = 0;
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if ($u >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", $v['cal']);
                            $pa = explode(",", str_replace(" ", ",", $ar1[0]));
                            if (count($pa) == '1') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 7);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    if (in_array($ar1[0], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '2') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 7);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '3') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 7);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '4') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 7);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr) && in_array($ae[3], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '5') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 7);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr) && in_array($ae[3], $qr) && in_array($ae[4], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else {
                                $cc = explode(",", rtrim($v['cal']));
                                $ty = str_replace(" ", ",", $cc[0]);
                                $rq = explode(",", str_replace(" ", ",", $cc[1]));
                                foreach ($rq as $k => $v) {
                                    $ne[] = $ty . ',' . $v;
                                }
                                foreach ($ne as $k1 => $v1) {
                                    $ts = explode(",", $v1);
                                    sort($ts);
                                    $ne[$k1] = implode(",", $ts);
                                }
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            $nstr = implode(",", $op);
                            foreach ($ne as $kk => $vv) {
                                $u = 0;
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[6], $op)) {
                                    $u++;
                                }
                                if ($u >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", $v['cal']);
                            $pa = explode(",", str_replace(" ", ",", $ar1[0]));
                            if (count($pa) == '1') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 8);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    if (in_array($ar1[0], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '2') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 8);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '3') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 8);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '4') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 8);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr) && in_array($ae[3], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '5') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 8);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr) && in_array($ae[3], $qr) && in_array($ae[4], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else if (count($pa) == '6') {
                                $cc = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                                $qu1 = getCombinationToString($cc, 8);
                                foreach ($qu1 as $kk => $vv) {
                                    $qr = explode(",", $vv);
                                    $ae = explode(",", str_replace(" ", ",", $ar1[0]));
                                    if (in_array($ae[0], $qr) && in_array($ae[1], $qr) && in_array($ae[2], $qr) && in_array($ae[3], $qr) && in_array($ae[4], $qr) && in_array($ae[5], $qr)) {
                                        $ne[] = $qu1[$kk];
                                    }
                                }
                            } else {
                                $cc = explode(",", rtrim($v['cal']));
                                $ty = str_replace(" ", ",", $cc[0]);
                                $rq = explode(",", str_replace(" ", ",", $cc[1]));
                                foreach ($rq as $k => $v) {
                                    $ne[] = $ty . ',' . $v;
                                }
                                foreach ($ne as $k1 => $v1) {
                                    $ts = explode(",", $v1);
                                    sort($ts);
                                    $ne[$k1] = implode(",", $ts);
                                }
                            }
                            foreach ($ne as $k1 => $v1) {
                                $ts = explode(",", $v1);
                                sort($ts);
                                $ne[$k1] = implode(",", $ts);
                            }
                            $op = explode(",", $resu['opencode']);
                            sort($op);
                            $nstr = implode(",", $op);
                            foreach ($ne as $kk => $vv) {
                                $u = 0;
                                $ab = explode(",", $vv);
                                if (in_array($ab[0], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[1], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[2], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[3], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[4], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[5], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[6], $op)) {
                                    $u++;
                                }
                                if (in_array($ab[7], $op)) {
                                    $u++;
                                }
                                if ($u >= 5) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                    }
                    $jieg[] = array($v['lottery_11x5_id'] => $resu['opencode']);
                }
            }
            foreach ($jieg as $kg => $vg) {
                foreach ($vg as $kt => $vt) {
                    if (!in_array($kt, $temp)) {
                        $temp[$kt] = $vt;
                    }
                }
            }
            $sq = "";
            foreach ($temp as $ki => $vi) {
                $sq .= " when id = {$ki} then '{$vi}' ";
            }
            $sql = "";
            if (!empty($sq)) {
                $sql .= ",opencode = CASE {$sq} else opencode end ";
            }
            if (!empty($sql)) {
                $sql = trim($sql, ',');
                $sql = "update " . C("DB_PREFIX") . "lottery_11x5 set {$sql}";
                M()->execute($sql);
            }
            foreach ($house6 as $k6 => $v6) {
                foreach ($arr as $ka => $va) {
                    if (array_search(trim($v6['issue']), $va)) {
                        if (!in_array($v6['id'], $zid)) {
                            $wz[] = $v6['id'];
                        }
                        break;
                    }
                }
            }
            if (!empty($wz)) {
                $ccd = implode(",", $wz);
                M("lottery_11x5_detail")->where("id in($ccd)")->save(array("is_zhong" => 2));
            }
            if (!empty($zid)) {
                $zd = implode(",", $zid);
                M("lottery_11x5_detail")->where("id in($zd)")->save(array("is_zhong" => 1));
                $res = M("lottery_11x5_detail d")
                    ->join(" join " . C("DB_PREFIX") . "lottery_11x5 s on d.lottery_11x5_id=s.id")
                    ->where("d.id in($zd)")
                    ->field("d.lottery_11x5_id,d.zo_money,s.uid")
                    ->select();
                foreach ($res as $kz => $vz) {
                    $uu[] = $vz['uid'];
                }
                $uz = implode(",", $uu);
                if ($uz) {
                    $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                }
                foreach ($res as $kp1 => $vp1) {
                    foreach ($mo as $kp2 => $vp2) {
                        if ($vp1['uid'] == $vp2['userid']) {
                            $res[$kp1]['money'] = $vp2['money'];
                        }
                    }
                }
                $total = 0;
                foreach ($res as $kp => $vp) {
                    $zz[] = $vp['lottery_11x5_id'];
                    $uudd[] = $vp['uid'];
                    $total += $vp['zo_money'];
                    $history_date7[] = array(
                        'number' => date("Ymd") . rand(100000, 999999),
                        'type' => '5',
                        'shou_money' => $vp['zo_money'],
                        'ky_money' => $vp['money'],
                        'ctime' => time(),
                        'uid' => $vp['uid'],
                        'remark' => '奖金派送'
                    );
                }
                $result = array();
                foreach ($res as $ke1 => $info) {
                    if ($result[$info['lottery_11x5_id']]) {
                        $result[$info['lottery_11x5_id']] += $info['zo_money'];
                    } else {
                        $result[$info['lottery_11x5_id']] = trim($info['zo_money']);
                    }
                }
                $result1 = array();
                foreach ($res as $ke2 => $info2) {
                    if ($result1[$info2['uid']]) {
                        $result1[$info2['uid']] += $info2['zo_money'];
                    } else {
                        $result1[$info2['uid']] = trim($info2['zo_money']);
                    }
                }
                foreach ($result1 as $kwi => $vwi) {
                    foreach ($mo as $k11 => $v11) {
                        if ($kwi == $v11['userid']) {
                            $result1[$kwi] = $vwi + $v11['money'];
                        }
                    }
                }
                $sq = "";
                $sq1 = "";
                foreach ($result as $ki => $vi) {
                    $sq .= " when id = {$ki} then '{$vi}' ";
                }
                foreach ($result1 as $ki1 => $vi1) {
                    $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                }
                $sql = "";
                if (!empty($sq)) {
                    $sql .= ",zong_money = CASE {$sq} else zong_money end ";
                }
                $sql1 = "";
                if (!empty($sq1)) {
                    $sql1 .= ",money = CASE {$sq1} else money end ";
                }
                if (!empty($sql)) {
                    $sql = trim($sql, ',');
                    $sql = "update " . C("DB_PREFIX") . "lottery_11x5 set {$sql}";
                    M()->execute($sql);
                }
                if (!empty($sql1)) {
                    $sql1 = trim($sql1, ',');
                    $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                    M()->execute($sql1);
                }
                M("jiaoyi")->addAll($history_date7);
            }
        }
        $wz = array();
        $zid = array();
        $jieg = array();
        $temp = array();
        //------------------判断时时彩-------------------------------------------
        $house9 = M("lottery_ssc_detail a")
            ->join(" join " . C("DB_PREFIX") . "lottery_ssc b on a.lottery_ssc_id = b.id")
            ->field(array("a.*,b.uid,b.issue,b.money,b.lotteryclass,b.status"))
            ->where("a.is_zhong = 0 and b.status = 0")
            ->select();
        if (!empty($house9)) {
            foreach ($house9 as $k => $v) {
                $resu = array();
                $arr = array();
                $qu = array();
                $a = 0;
                $b = 0;
                $ne = array();
                $n = 0;
                $str = array();
                $s = array();
                $s1 = array();
                if ($v['lotteryclass'] == '15') {
                    $arr = $this->get_data2("cqssc");
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 15, $v['issue']);
                    }
                }
                if ($v['lotteryclass'] == '17') {
                    $arr = $this->get_data("xjssc");
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 17, $v['issue']);
                    }
                }
                if ($v['lotteryclass'] == '18') {
                    $arr = $this->get_data2("tjssc");
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 18, $v['issue']);
                    }
                }
                if ($v['lotteryclass'] == '19') {
                    $arr = $this->get_data("ffc2");
                    if (empty($arr)) {
                        $arr = $this->ren_gong($ren_gong, 19, $v['issue']);
                    }
                }
                foreach ($arr as $ka => $va) {
                    if (array_search(trim($v['issue']), $va)) {
                        $resu = $arr[$ka];
                        break;
                    }
                }
                if (!empty($resu)) {
                    //五星
                    if ($v['type'] == '1') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $pa1 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $pa2 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $pa3 = explode(",", str_replace(" ", ",", $ar1[2]));
                            $pa4 = explode(",", str_replace(" ", ",", $ar1[3]));
                            $pa5 = explode(",", str_replace(" ", ",", $ar1[4]));
                            $narr = array();
                            foreach ($pa1 as $ka => $va) {
                                foreach ($pa2 as $kb => $vb) {
                                    foreach ($pa3 as $kc => $vc) {
                                        foreach ($pa4 as $kq => $vq) {
                                            foreach ($pa5 as $kt => $vt) {
                                                if (isset($va) && isset($vb) && isset($vc) && isset($vq) && isset($vt)) {
                                                    $narr[] = $va . ',' . $vb . ',' . $vc . ',' . $vq . ',' . $vt;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            foreach ($narr as $ki => $vi) {
                                $ts = explode(",", $vi);
                                $narr[$ki] = implode(",", $ts);
                            }
                            $op = explode(",", $resu['opencode']);
                            $nstr = implode(",", $op);
                            if (in_array($nstr, $narr)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ns = str_replace(",", "", $resu['opencode']);
                            if (in_array($ns, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 5);
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($ar2 as $ky => $vy) {
                                if ($tt === $vy) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ar2 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $ar3 = str_replace(" ", ",", $ar1[1]);
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $tt = implode(",", $nt);
                            $y = array();
                            foreach ($ar2 as $ky => $vy) {
                                $y[] = $vy . ',' . $vy . ',' . $ar3;
                            }
                            foreach ($y as $kk => $vv) {
                                $ts = explode(",", $vv);
                                sort($ts);
                                $y[$kk] = implode(",", $ts);
                            }
                            foreach ($y as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ar2 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $ar5 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $yu = array();
                            $ttt = array();
                            $ar3 = getCombinationToString($ar2, 2);
                            foreach ($ar3 as $kq => $vq) {
                                $yu[] = $vq . ',' . $vq;
                            }
                            foreach ($yu as $kk => $vv) {
                                foreach ($ar5 as $kc => $vc) {
                                    $ts = explode(",", $vv);
                                    sort($ts);
                                    if (!in_array($vc, $ts)) {
                                        $ts[] = $vc;
                                        $ttt[] = implode(",", $ts);
                                    }
                                }
                            }
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($ttt as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ar2 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $ar5 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $yu = array();
                            $ttt = array();
                            $ar6 = getCombinationToString($ar5, 2);
                            foreach ($ar2 as $kq => $vq) {
                                $yu[] = $vq . ',' . $vq . ',' . $vq;
                            }
                            foreach ($yu as $kk => $vv) {
                                foreach ($ar6 as $kc => $vc) {
                                    $ts = explode(",", $vv);
                                    sort($ts);
                                    $vs = explode(",", $vc);
                                    if (!in_array($vs[0], $ts) && !in_array($vs[1], $ts)) {
                                        $ts[] = $vc;
                                        $ttt[] = implode(",", $ts);
                                    }
                                }
                            }
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($ttt as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ar2 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $ar5 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $yu = array();
                            $ttt = array();
                            foreach ($ar2 as $kq => $vq) {
                                $yu[] = $vq . ',' . $vq . ',' . $vq;
                            }
                            foreach ($yu as $kk => $vv) {
                                foreach ($ar5 as $kc => $vc) {
                                    $ts = explode(",", $vv);
                                    sort($ts);
                                    if (!in_array($vc, $ts)) {
                                        $ts[] = $vc . ',' . $vc;
                                        $ttt[] = implode(",", $ts);
                                    }
                                }
                            }
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($ttt as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ar2 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $ar5 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $yu = array();
                            $ttt = array();
                            foreach ($ar2 as $kq => $vq) {
                                $yu[] = $vq . ',' . $vq . ',' . $vq . ',' . $vq;
                            }
                            foreach ($yu as $kk => $vv) {
                                foreach ($ar5 as $kc => $vc) {
                                    $ts = explode(",", $vv);
                                    sort($ts);
                                    if (!in_array($vc, $ts)) {
                                        $ts[] = $vc;
                                        $ttt[] = implode(",", $ts);
                                    }
                                }
                            }
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($ttt as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '9' || $v['m_type'] == '12') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", $resu['opencode']);
                            foreach ($ar1 as $kk => $vv) {
                                if (in_array($vv, $nt)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '10') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 2);
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            foreach ($ar2 as $kk => $vv) {
                                $ca = explode(",", $vv);
                                if (in_array($ca[0], $nt)) {
                                    if (in_array($ca[1], $nt)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        //三码不定位
                        if ($v['m_type'] == '11') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 3);
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            foreach ($ar2 as $kk => $vv) {
                                $ca = explode(",", $vv);
                                if (in_array($ca[0], $nt)) {
                                    if (in_array($ca[1], $nt)) {
                                        if (in_array($ca[2], $nt)) {
                                            //中奖
                                            $zid[] = $v['id'];
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        //好事成双
                        if ($v['m_type'] == '13') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $rt = array_count_values($nt);
                            foreach ($rt as $ka => $va) {
                                if ($va < 2) {
                                    unset($rt[$ka]);
                                }
                            }
                            foreach ($ar1 as $kk => $vv) {
                                foreach ($rt as $kc => $vc) {
                                    if ($vv == $kc) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }

                            }
                        }
                        if ($v['m_type'] == '14') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $rt = array_count_values($nt);
                            foreach ($rt as $ka => $va) {
                                if ($va < 3) {
                                    unset($rt[$ka]);
                                }
                            }
                            foreach ($ar1 as $kk => $vv) {
                                foreach ($rt as $kc => $vc) {
                                    if ($vv == $kc) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }

                            }
                        }
                        if ($v['m_type'] == '15') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", $resu['opencode']);
                            sort($nt);
                            $rt = array_count_values($nt);
                            foreach ($rt as $ka => $va) {
                                if ($va < 4) {
                                    unset($rt[$ka]);
                                }
                            }
                            foreach ($ar1 as $kk => $vv) {
                                foreach ($rt as $kc => $vc) {
                                    if ($vv == $kc) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }

                            }
                        }
                    }
                    //四星
                    if ($v['type'] == '2') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $pa1 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $pa2 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $pa3 = explode(",", str_replace(" ", ",", $ar1[2]));
                            $pa4 = explode(",", str_replace(" ", ",", $ar1[3]));
                            $narr = array();
                            foreach ($pa1 as $ka => $va) {
                                foreach ($pa2 as $kb => $vb) {
                                    foreach ($pa3 as $kc => $vc) {
                                        foreach ($pa4 as $kq => $vq) {
                                            if ($va && $vb && $vc && $vq) {
                                                $narr[] = $va . ',' . $vb . ',' . $vc . ',' . $vq;
                                            }
                                        }
                                    }
                                }
                            }
                            foreach ($narr as $ki => $vi) {
                                $ts = explode(",", $vi);
                                sort($ts);
                                $narr[$ki] = implode(",", $ts);
                            }
                            $op = explode(",", substr($resu['opencode'], 2));
                            sort($op);
                            $nstr = implode(",", $op);
                            if (in_array($nstr, $narr)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $aa = str_replace(",", "", substr($resu['opencode'], 2));
                            foreach ($ar1 as $ki => $vi) {
                                if ($vi === $aa) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 4);
                            $aa = explode(",", substr($resu['opencode'], 2));
                            sort($aa);
                            $bb = implode(",", $aa);
                            foreach ($ar2 as $ki => $vi) {
                                if ($vi === $bb) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ar2 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $ar5 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $yu = array();
                            $ttt = array();
                            $ar6 = getCombinationToString($ar5, 2);
                            foreach ($ar2 as $kq => $vq) {
                                $yu[] = $vq . ',' . $vq;
                            }
                            foreach ($yu as $kk => $vv) {
                                foreach ($ar6 as $kc => $vc) {
                                    $ts = explode(",", $vv);
                                    sort($ts);
                                    $vs = explode(",", $vc);
                                    if (!in_array($vs[0], $ts) && !in_array($vs[1], $ts)) {
                                        $ts[] = $vc;
                                        $ttt[] = implode(",", $ts);
                                    }
                                }
                            }
                            $nt = explode(",", substr($resu['opencode'], 2));
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($ttt as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $yu = array();
                            $ar6 = getCombinationToString($ar1, 2);
                            foreach ($ar6 as $kq => $vq) {
                                $ts = explode(",", $vq);
                                $yu[] = $ts[0] . ',' . $ts[0] . ',' . $ts[1] . ',' . $ts[1];
                            }
                            $nt = explode(",", substr($resu['opencode'], 2));
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($yu as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $ar2 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $ar5 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $yu = array();
                            $ttt = array();
                            foreach ($ar2 as $kq => $vq) {
                                $yu[] = $vq . ',' . $vq . ',' . $vq;
                            }
                            foreach ($yu as $kk => $vv) {
                                foreach ($ar5 as $kc => $vc) {
                                    $ts = explode(",", $vv);
                                    if (!in_array($vc, $ts)) {
                                        $ts[] = $vc;
                                        sort($ts);
                                        $ttt[] = implode(",", $ts);
                                    }
                                }
                            }
                            $nt = explode(",", substr($resu['opencode'], 2));
                            sort($nt);
                            $tt = implode(",", $nt);
                            foreach ($ttt as $kk1 => $vv1) {
                                if ($tt === $vv1) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", substr($resu['opencode'], 2));
                            foreach ($ar1 as $kk => $vv) {
                                if (in_array($vv, $nt)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 2);
                            $nt = explode(",", substr($resu['opencode'], 2));
                            sort($nt);
                            foreach ($ar2 as $kk => $vv) {
                                $ca = explode(",", $vv);
                                if (in_array($ca[0], $nt)) {
                                    if (in_array($ca[1], $nt)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    //前三
                    if ($v['type'] == '3') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $pa1 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $pa2 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $pa3 = explode(",", str_replace(" ", ",", $ar1[2]));
                            $narr = array();
                            foreach ($pa1 as $ka => $va) {
                                foreach ($pa2 as $kb => $vb) {
                                    foreach ($pa3 as $kc => $vc) {
                                        if ($va && $vb && $vc) {
                                            $narr[] = $va . ',' . $vb . ',' . $vc;
                                        }
                                    }
                                }
                            }
                            $op = explode(",", $resu['opencode']);
                            $nstr = implode(",", $op);
                            if (in_array(substr($nstr, 0, 5), $narr)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $cc = str_replace(",", "", substr($resu['opencode'], 0, 5));
                            if (in_array($cc, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            $he = $cc[0] + $cc[1] + $cc[2];
                            if (in_array($he, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            sort($cc);
                            $cha = $cc[2] - $cc[0];
                            if (in_array($cha, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            if ($cc[0] != $cc[1] && $cc[1] != $cc[2]) {
                                $cha = $cc[0] + $cc[1] + $cc[2];
                                if (in_array($cha, $ar1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nr = array();
                            foreach ($ar1 as $kk => $vv) {
                                $nr[] = $vv . ',' . $vv;
                            }
                            $cr = array();
                            foreach ($nr as $key => $value) {
                                $vt = explode(",", $value);
                                foreach ($ar1 as $ka => $va) {
                                    if (!in_array($va, $vt)) {
                                        $cr[] = $value . ',' . $va;
                                    }
                                }
                            }
                            foreach ($cr as $ky => $vy) {
                                $tu = explode(",", $vy);
                                sort($tu);
                                $cr[$ky] = implode(",", $tu);
                            }
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            sort($cc);
                            $ch = implode(",", $cc);
                            foreach ($cr as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cp = getCombinationToString($ar1, 3);
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            sort($cc);
                            $ch = implode(",", $cc);
                            foreach ($cp as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            foreach ($ar1 as $kk => $vv) {
                                $ca = substr_cut($vv);
                                sort($ca);
                                $ar1[$kk] = str_replace(",", "", implode(",", $ca));
                            }
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            sort($cc);
                            $ch = str_replace(",", "", implode(",", $cc));
                            foreach ($ar1 as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '9') {
                            $ar = trim($v['cal']);
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            if ($cc[0] != $cc[1]) {
                                sort($cc);
                                foreach ($cc as $ki => $vi) {
                                    if ($ar === $vi) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '10' || $v['m_type'] == '11') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            foreach ($ar1 as $kk => $vv) {
                                $ca = substr_cut($vv);
                                sort($ca);
                                $ar1[$kk] = str_replace(",", "", implode(",", $ca));
                            }
                            $cc = explode(",", substr($resu['opencode'], 0, 5));
                            sort($cc);
                            $ch = str_replace(",", "", implode(",", $cc));
                            foreach ($ar1 as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '12') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", substr($resu['opencode'], 0, 5));
                            foreach ($ar1 as $kk => $vv) {
                                if (in_array($vv, $nt)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '13') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 2);
                            $nt = explode(",", substr($resu['opencode'], 0, 5));
                            sort($nt);
                            foreach ($ar2 as $kk => $vv) {
                                $ca = explode(",", $vv);
                                if (in_array($ca[0], $nt)) {
                                    if (in_array($ca[1], $nt)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    //中三
                    if ($v['type'] == '4') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $pa1 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $pa2 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $pa3 = explode(",", str_replace(" ", ",", $ar1[2]));
                            $narr = array();
                            foreach ($pa1 as $ka => $va) {
                                foreach ($pa2 as $kb => $vb) {
                                    foreach ($pa3 as $kc => $vc) {
                                        if ($va && $vb && $vc) {
                                            $narr[] = $va . ',' . $vb . ',' . $vc;
                                        }
                                    }
                                }
                            }
                            $op = explode(",", $resu['opencode']);
                            $nstr = implode(",", $op);
                            if (in_array(substr($nstr, 2, 5), $narr)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $cc = str_replace(",", "", substr($resu['opencode'], 2, 5));
                            if (in_array($cc, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            $he = $cc[0] + $cc[1] + $cc[2];
                            if (in_array($he, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            sort($cc);
                            $cha = $cc[2] - $cc[0];
                            if (in_array($cha, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            if ($cc[0] != $cc[1] && $cc[1] != $cc[2]) {
                                $cha = $cc[0] + $cc[1] + $cc[2];
                                if (in_array($cha, $ar1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nr = array();
                            foreach ($ar1 as $kk => $vv) {
                                $nr[] = $vv . ',' . $vv;
                            }
                            $cr = array();
                            foreach ($nr as $key => $value) {
                                $vt = explode(",", $value);
                                foreach ($ar1 as $ka => $va) {
                                    if (!in_array($va, $vt)) {
                                        $cr[] = $value . ',' . $va;
                                    }
                                }
                            }
                            foreach ($cr as $ky => $vy) {
                                $tu = explode(",", $vy);
                                sort($tu);
                                $cr[$ky] = implode(",", $tu);
                            }
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            sort($cc);
                            $ch = implode(",", $cc);
                            foreach ($cr as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cp = getCombinationToString($ar1, 3);
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            sort($cc);
                            $ch = implode(",", $cc);
                            foreach ($cp as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            foreach ($ar1 as $kk => $vv) {
                                $ca = substr_cut($vv);
                                sort($ca);
                                $ar1[$kk] = str_replace(",", "", implode(",", $ca));
                            }
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            sort($cc);
                            $ch = str_replace(",", "", implode(",", $cc));
                            foreach ($ar1 as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '9') {
                            $ar = trim($v['cal']);
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            if ($cc[0] != $cc[1]) {
                                sort($cc);
                                foreach ($cc as $ki => $vi) {
                                    if ($ar === $vi) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '10' || $v['m_type'] == '11') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            foreach ($ar1 as $kk => $vv) {
                                $ca = substr_cut($vv);
                                sort($ca);
                                $ar1[$kk] = str_replace(",", "", implode(",", $ca));
                            }
                            $cc = explode(",", substr($resu['opencode'], 2, 5));
                            sort($cc);
                            $ch = str_replace(",", "", implode(",", $cc));
                            foreach ($ar1 as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '12') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", substr($resu['opencode'], 2, 5));
                            foreach ($ar1 as $kk => $vv) {
                                if (in_array($vv, $nt)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '13') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 2);
                            $nt = explode(",", substr($resu['opencode'], 2, 5));
                            sort($nt);
                            foreach ($ar2 as $kk => $vv) {
                                $ca = explode(",", $vv);
                                if (in_array($ca[0], $nt)) {
                                    if (in_array($ca[1], $nt)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    //后三
                    if ($v['type'] == '5') {
                        if ($v['m_type'] == '1') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $pa1 = explode(",", str_replace(" ", ",", $ar1[0]));
                            $pa2 = explode(",", str_replace(" ", ",", $ar1[1]));
                            $pa3 = explode(",", str_replace(" ", ",", $ar1[2]));
                            $narr = array();
                            foreach ($pa1 as $ka => $va) {
                                foreach ($pa2 as $kb => $vb) {
                                    foreach ($pa3 as $kc => $vc) {
                                        if ($va && $vb && $vc) {
                                            $narr[] = $va . ',' . $vb . ',' . $vc;
                                        }
                                    }
                                }
                            }
                            $op = explode(",", $resu['opencode']);
                            $nstr = implode(",", $op);
                            if (in_array(substr($nstr, 4), $narr)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            $cc = str_replace(",", "", substr($resu['opencode'], 4));
                            if (in_array($cc, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 4));
                            $he = $cc[0] + $cc[1] + $cc[2];
                            if (in_array($he, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 4));
                            sort($cc);
                            $cha = $cc[2] - $cc[0];
                            if (in_array($cha, $ar1)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cc = explode(",", substr($resu['opencode'], 4));
                            if ($cc[0] != $cc[1] && $cc[1] != $cc[2]) {
                                $cha = $cc[0] + $cc[1] + $cc[2];
                                if (in_array($cha, $ar1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nr = array();
                            foreach ($ar1 as $kk => $vv) {
                                $nr[] = $vv . ',' . $vv;
                            }
                            $cr = array();
                            foreach ($nr as $key => $value) {
                                $vt = explode(",", $value);
                                foreach ($ar1 as $ka => $va) {
                                    if (!in_array($va, $vt)) {
                                        $cr[] = $value . ',' . $va;
                                    }
                                }
                            }
                            foreach ($cr as $ky => $vy) {
                                $tu = explode(",", $vy);
                                sort($tu);
                                $cr[$ky] = implode(",", $tu);
                            }
                            $cc = explode(",", substr($resu['opencode'], 4));
                            sort($cc);
                            $ch = implode(",", $cc);
                            foreach ($cr as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $cp = getCombinationToString($ar1, 3);
                            $cc = explode(",", substr($resu['opencode'], 4));
                            sort($cc);
                            $ch = implode(",", $cc);
                            foreach ($cp as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            foreach ($ar1 as $kk => $vv) {
                                $ca = substr_cut($vv);
                                sort($ca);
                                $ar1[$kk] = str_replace(",", "", implode(",", $ca));
                            }
                            $cc = explode(",", substr($resu['opencode'], 4));
                            sort($cc);
                            $ch = str_replace(",", "", implode(",", $cc));
                            foreach ($ar1 as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '9') {
                            $ar = trim($v['cal']);
                            $cc = explode(",", substr($resu['opencode'], 4));
                            if ($cc[0] != $cc[1]) {
                                sort($cc);
                                foreach ($cc as $ki => $vi) {
                                    if ($ar === $vi) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '10' || $v['m_type'] == '11') {
                            $ar1 = explode(",", rtrim($v['cal']));
                            foreach ($ar1 as $kk => $vv) {
                                $ca = substr_cut($vv);
                                sort($ca);
                                $ar1[$kk] = str_replace(",", "", implode(",", $ca));
                            }
                            $cc = explode(",", substr($resu['opencode'], 4));
                            sort($cc);
                            $ch = str_replace(",", "", implode(",", $cc));
                            foreach ($ar1 as $ki => $vi) {
                                if ($ch === $vi) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '12') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nt = explode(",", substr($resu['opencode'], 4));
                            foreach ($ar1 as $kk => $vv) {
                                if (in_array($vv, $nt)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '13') {
                            $ar1 = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $ar2 = getCombinationToString($ar1, 2);
                            $nt = explode(",", substr($resu['opencode'], 4));
                            sort($nt);
                            foreach ($ar2 as $kk => $vv) {
                                $ca = explode(",", $vv);
                                if (in_array($ca[0], $nt)) {
                                    if (in_array($ca[1], $nt)) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    //前二
                    if ($v['type'] == '6') {
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr1 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr1[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr1[1]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    $qu[] = $v1 . ',' . $v2;
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 0, 3) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $a = rtrim($v['cal']);
                            $ar1 = explode(",", $a);
                            $aa = str_replace(",", "", substr($resu['opencode'], 0, 3));
                            foreach ($ar1 as $kk => $vv) {
                                if ($aa === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $aa = explode(",", substr($resu['opencode'], 0, 3));
                            $he = $aa[0] + $aa[1];
                            if (in_array($he, $a)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $aa = explode(",", substr($resu['opencode'], 0, 3));
                            sort($aa);
                            $he = $aa[1] - $aa[0];
                            if (in_array($he, $a)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nar = getCombinationToString($a, 2);
                            $aa = explode(",", substr($resu['opencode'], 0, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                $bb = implode(",", $aa);
                                foreach ($nar as $ka => $va) {
                                    if ($bb === $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $a = explode(",", rtrim($v['cal']));
                            $aa = explode(",", substr($resu['opencode'], 0, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                $bb = str_replace(",", "", implode(",", $aa));
                                foreach ($a as $ka => $va) {
                                    if ($bb === $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $aa = explode(",", substr($resu['opencode'], 0, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                $bb = $aa[0] + $aa[1];
                                foreach ($a as $ka => $va) {
                                    if ($bb == $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $a = rtrim($v['cal']);
                            $aa = explode(",", substr($resu['opencode'], 0, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                foreach ($aa as $ka => $va) {
                                    if ($a == $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    //后二
                    if ($v['type'] == '7') {
                        if ($v['m_type'] == '1') {
                            $a = rtrim($v['cal']);
                            $arr1 = explode(",", $a);
                            $a1 = explode(",", str_replace(" ", ",", $arr1[0]));
                            $a2 = explode(",", str_replace(" ", ",", $arr1[1]));
                            foreach ($a1 as $k1 => $v1) {
                                foreach ($a2 as $k2 => $v2) {
                                    $qu[] = $v1 . ',' . $v2;
                                }
                            }
                            foreach ($qu as $kk => $vv) {
                                if (substr($resu['opencode'], 6, 3) === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '2') {
                            $a = rtrim($v['cal']);
                            $ar1 = explode(",", $a);
                            $aa = str_replace(",", "", substr($resu['opencode'], 6, 3));
                            foreach ($ar1 as $kk => $vv) {
                                if ($aa === $vv) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                        }
                        if ($v['m_type'] == '3') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $aa = explode(",", substr($resu['opencode'], 6, 3));
                            $he = $aa[0] + $aa[1];
                            if (in_array($he, $a)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '4') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $aa = explode(",", substr($resu['opencode'], 6, 3));
                            sort($aa);
                            $he = $aa[1] - $aa[0];
                            if (in_array($he, $a)) {
                                //中奖
                                $zid[] = $v['id'];
                            }
                        }
                        if ($v['m_type'] == '5') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $nar = getCombinationToString($a, 2);
                            $aa = explode(",", substr($resu['opencode'], 6, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                $bb = implode(",", $aa);
                                foreach ($nar as $ka => $va) {
                                    if ($bb === $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '6') {
                            $a = explode(",", rtrim($v['cal']));
                            $aa = explode(",", substr($resu['opencode'], 6, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                $bb = str_replace(",", "", implode(",", $aa));
                                foreach ($a as $ka => $va) {
                                    if ($bb === $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '7') {
                            $a = explode(",", str_replace(" ", ",", rtrim($v['cal'])));
                            $aa = explode(",", substr($resu['opencode'], 6, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                $bb = $aa[0] + $aa[1];
                                foreach ($a as $ka => $va) {
                                    if ($bb == $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                        if ($v['m_type'] == '8') {
                            $a = rtrim($v['cal']);
                            $aa = explode(",", substr($resu['opencode'], 6, 3));
                            sort($aa);
                            if ($aa[0] != $aa[1]) {
                                foreach ($aa as $ka => $va) {
                                    if ($a == $va) {
                                        //中奖
                                        $zid[] = $v['id'];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    //一星
                    if ($v['type'] == '8') {
                        $a = rtrim($v['cal']);
                        $arr1 = explode(",", $a);
                        $arr2 = explode(",", $resu['opencode']);
                        for ($i = 0; $i < 5; $i++) {
                            if (!empty($arr1[$i])) {
                                $ara = explode(",", str_replace(" ", ",", $arr1[$i]));
                                if (in_array($arr2[$i], $ara)) {
                                    $zid[] = $v['id'];
                                    continue;
                                } else {
                                    continue;
                                }
                            }
                        }
                        $zid = array_unique($zid);
                    }
                    if ($v['type'] == '9') {
                        if ($v['m_type'] == '1') {
                            $n = explode(",", rtrim($v['cal']));
                            $qian = explode(",", str_replace(" ", ",", $n[0]));
                            $hou = explode(",", str_replace(" ", ",", $n[1]));
                            $arrt = explode(",", substr($resu['opencode'], 0, 3));
                            if ($arrt[0] >= 0 && $arrt[0] <= 4) {
                                $str[] = "小";
                            }
                            if ($arrt[0] >= 5 && $arrt[0] <= 9) {
                                $str[] = "大";
                            }
                            if ($arrt[0] % 2 == 0) {
                                $str[] = "双";
                            } else {
                                $str[] = "单";
                            }
                            if ($arrt[1] >= 0 && $arrt[1] <= 4) {
                                $s[] = "小";
                            }
                            if ($arrt[1] >= 5 && $arrt[1] <= 9) {
                                $s[] = "大";
                            }
                            if ($arrt[1] % 2 == 0) {
                                $s[] = "双";
                            } else {
                                $s[] = "单";
                            }
                            foreach ($qian as $ka => $va) {
                                if (in_array($va, $str)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            foreach ($hou as $ka1 => $va1) {
                                if (in_array($va1, $s)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }

                            $zid = array_unique($zid);
                        }
                        if ($v['m_type'] == '2') {
                            $n = explode(",", rtrim($v['cal']));
                            $qian = explode(",", str_replace(" ", ",", $n[0]));
                            $hou = explode(",", str_replace(" ", ",", $n[1]));
                            $arrt = explode(",", substr($resu['opencode'], 6, 3));
                            if ($arrt[0] >= 0 && $arrt[0] <= 4) {
                                $str[] = "小";
                            }
                            if ($arrt[0] >= 5 && $arrt[0] <= 9) {
                                $str[] = "大";
                            }
                            if ($arrt[0] % 2 == 0) {
                                $str[] = "双";
                            } else {
                                $str[] = "单";
                            }
                            if ($arrt[1] >= 0 && $arrt[1] <= 4) {
                                $s[] = "小";
                            }
                            if ($arrt[1] >= 5 && $arrt[1] <= 9) {
                                $s[] = "大";
                            }
                            if ($arrt[1] % 2 == 0) {
                                $s[] = "双";
                            } else {
                                $s[] = "单";
                            }
                            foreach ($qian as $ka => $va) {
                                if (in_array($va, $str)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            foreach ($hou as $ka1 => $va1) {
                                if (in_array($va1, $s)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            $zid = array_unique($zid);
                        }
                        if ($v['m_type'] == '3') {
                            $n = explode(",", rtrim($v['cal']));
                            $qian = explode(",", str_replace(" ", ",", $n[0]));
                            $zhong = explode(",", str_replace(" ", ",", $n[1]));
                            $hou = explode(",", str_replace(" ", ",", $n[2]));
                            $arrt = explode(",", substr($resu['opencode'], 0, 5));
                            if ($arrt[0] >= 0 && $arrt[0] <= 4) {
                                $str[] = "小";
                            }
                            if ($arrt[0] >= 5 && $arrt[0] <= 9) {
                                $str[] = "大";
                            }
                            if ($arrt[0] % 2 == 0) {
                                $str[] = "双";
                            } else {
                                $str[] = "单";
                            }
                            if ($arrt[1] >= 0 && $arrt[1] <= 4) {
                                $s[] = "小";
                            }
                            if ($arrt[1] >= 5 && $arrt[1] <= 9) {
                                $s[] = "大";
                            }
                            if ($arrt[1] % 2 == 0) {
                                $s[] = "双";
                            } else {
                                $s[] = "单";
                            }
                            if ($arrt[2] >= 0 && $arrt[2] <= 4) {
                                $s1[] = "小";
                            }
                            if ($arrt[2] >= 5 && $arrt[2] <= 9) {
                                $s1[] = "大";
                            }
                            if ($arrt[2] % 2 == 0) {
                                $s1[] = "双";
                            } else {
                                $s1[] = "单";
                            }
                            foreach ($qian as $ka => $va) {
                                if (in_array($va, $str)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            foreach ($zhong as $ka1 => $va1) {
                                if (in_array($va1, $s)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            foreach ($hou as $ka1 => $va1) {
                                if (in_array($va1, $s1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            $zid = array_unique($zid);
                        }
                        if ($v['m_type'] == '4') {
                            $n = explode(",", rtrim($v['cal']));
                            $qian = explode(",", str_replace(" ", ",", $n[0]));
                            $zhong = explode(",", str_replace(" ", ",", $n[1]));
                            $hou = explode(",", str_replace(" ", ",", $n[2]));
                            $arrt = explode(",", substr($resu['opencode'], 4));
                            if ($arrt[0] >= 0 && $arrt[0] <= 4) {
                                $str[] = "小";
                            }
                            if ($arrt[0] >= 5 && $arrt[0] <= 9) {
                                $str[] = "大";
                            }
                            if ($arrt[0] % 2 == 0) {
                                $str[] = "双";
                            } else {
                                $str[] = "单";
                            }
                            if ($arrt[1] >= 0 && $arrt[1] <= 4) {
                                $s[] = "小";
                            }
                            if ($arrt[1] >= 5 && $arrt[1] <= 9) {
                                $s[] = "大";
                            }
                            if ($arrt[1] % 2 == 0) {
                                $s[] = "双";
                            } else {
                                $s[] = "单";
                            }
                            if ($arrt[2] >= 0 && $arrt[2] <= 4) {
                                $s1[] = "小";
                            }
                            if ($arrt[2] >= 5 && $arrt[2] <= 9) {
                                $s1[] = "大";
                            }
                            if ($arrt[2] % 2 == 0) {
                                $s1[] = "双";
                            } else {
                                $s1[] = "单";
                            }
                            foreach ($qian as $ka => $va) {
                                if (in_array($va, $str)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            foreach ($zhong as $ka1 => $va1) {
                                if (in_array($va1, $s)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            foreach ($hou as $ka1 => $va1) {
                                if (in_array($va1, $s1)) {
                                    //中奖
                                    $zid[] = $v['id'];
                                    break;
                                }
                            }
                            $zid = array_unique($zid);
                        }
                    }
                    $jieg[] = array($v['lottery_ssc_id'] => $resu['opencode']);
                }
            }
            foreach ($jieg as $kg => $vg) {
                foreach ($vg as $kt => $vt) {
                    if (!in_array($kt, $temp)) {
                        $temp[$kt] = $vt;
                    }
                }
            }
            $sq = "";
            foreach ($temp as $ki => $vi) {
                $sq .= " when id = {$ki} then '{$vi}' ";
            }
            $sql = "";
            if (!empty($sq)) {
                $sql .= ",opencode = CASE {$sq} else opencode end ";
            }
            if (!empty($sql)) {
                $sql = trim($sql, ',');
                $sql = "update " . C("DB_PREFIX") . "lottery_ssc set {$sql}";
                M()->execute($sql);
            }
            foreach ($house9 as $k9 => $v9) {
                foreach ($arr as $ka => $va) {
                    if (array_search(trim($v9['issue']), $va)) {
                        if (!in_array($v9['id'], $zid)) {
                            $wz[] = $v9['id'];
                        }
                        break;
                    }
                }
            }
            if (!empty($wz)) {
                $ccd = implode(",", $wz);
                M("lottery_ssc_detail")->where("id in($ccd)")->save(array("is_zhong" => 2));
            }
            if (!empty($zid)) {
                $zd = implode(",", $zid);
                M("lottery_ssc_detail")->where("id in($zd)")->save(array("is_zhong" => 1));

                $res = M("lottery_ssc_detail d")
                    ->join(" join " . C("DB_PREFIX") . "lottery_ssc s on d.lottery_ssc_id=s.id")
                    ->where("d.id in($zd)")
                    ->field(array("d.*,s.uid,s.issue,s.money,s.lotteryclass,s.status"))
                    ->select();
                foreach ($res as $k => $v) {
                    if ($v['lotteryclass'] == '15') {
                        $arr = $this->get_data2("cqssc");
                        if (empty($arr)) {
                            $arr = $this->ren_gong($ren_gong, 15, $v['issue']);
                        }
                    }
                    if ($v['lotteryclass'] == '17') {
                        $arr = $this->get_data("xjssc");
                        if (empty($arr)) {
                            $arr = $this->ren_gong($ren_gong, 17, $v['issue']);
                        }
                    }
                    if ($v['lotteryclass'] == '18') {
                        $arr = $this->get_data2("tjssc");
                        if (empty($arr)) {
                            $arr = $this->ren_gong($ren_gong, 18, $v['issue']);
                        }
                    }
                    if ($v['lotteryclass'] == '19') {
                        $arr = $this->get_data("ffc2");
                        if (empty($arr)) {
                            $arr = $this->ren_gong($ren_gong, 19, $v['issue']);
                        }
                    }
                    foreach ($arr as $ka => $va) {
                        if (array_search(trim($v['issue']), $va)) {
                            $resu = $arr[$ka];
                            break;
                        }
                    }
                    if (!empty($resu)) {
                        if ($v['type'] == '8') {
                            $zj = 0;
                            $a = rtrim($v['cal']);
                            $arr1 = explode(",", $a);
                            $arr2 = explode(",", $resu['opencode']);
                            for ($i = 0; $i < 5; $i++) {
                                if (!empty($arr1[$i])) {
                                    $ara = explode(",", str_replace(" ", ",", $arr1[$i]));
                                    if (in_array($arr2[$i], $ara)) {
                                        $zid[] = $v['id'];
                                        $zj++;
                                        continue;
                                    } else {
                                        continue;
                                    }
                                }
                            }
                            $res[$k]['zo_money'] = $zj * $v['zo_money'];
                        }
                    }
                }
                foreach ($res as $kz => $vz) {
                    $uu[] = $vz['uid'];
                }
                $uz = implode(",", $uu);
                if ($uz) {
                    $mo = M('Accountsinfo')->where("userid in($uz)")->select();
                }
                foreach ($res as $kp1 => $vp1) {
                    foreach ($mo as $kp2 => $vp2) {
                        if ($vp1['uid'] == $vp2['userid']) {
                            $res[$kp1]['money'] = $vp2['money'];
                        }
                    }
                }
                $total = 0;
                foreach ($res as $kp => $vp) {
                    $zz[] = $vp['lottery_ssc_id'];
                    $uudd[] = $vp['uid'];
                    $total += $vp['zo_money'];
                    $history_date8[] = array(
                        'number' => date("Ymd") . rand(100000, 999999),
                        'type' => '5',
                        'shou_money' => $vp['zo_money'],
                        'ky_money' => $vp['money'],
                        'ctime' => time(),
                        'uid' => $vp['uid'],
                        'remark' => '奖金派送'
                    );
                }
                $result = array();
                foreach ($res as $ke1 => $info) {
                    if ($result[$info['lottery_ssc_id']]) {
                        $result[$info['lottery_ssc_id']] += $info['zo_money'];
                    } else {
                        $result[$info['lottery_ssc_id']] = trim($info['zo_money']);
                    }
                }
                $result1 = array();
                foreach ($res as $ke2 => $info2) {
                    if ($result1[$info2['uid']]) {
                        $result1[$info2['uid']] += $info2['zo_money'];
                    } else {
                        $result1[$info2['uid']] = trim($info2['zo_money']);
                    }
                }
                foreach ($result1 as $kwi => $vwi) {
                    foreach ($mo as $k11 => $v11) {
                        if ($kwi == $v11['userid']) {
                            $result1[$kwi] = $vwi + $v11['money'];
                        }
                    }
                }
                $sq = "";
                $sq1 = "";
                foreach ($result as $ki => $vi) {
                    $sq .= " when id = {$ki} then '{$vi}' ";
                }
                foreach ($result1 as $ki1 => $vi1) {
                    $sq1 .= " when userid = {$ki1} then '{$vi1}' ";
                }
                $sql = "";
                if (!empty($sq)) {
                    $sql .= ",zong_money = CASE {$sq} else zong_money end ";
                }
                $sql1 = "";
                if (!empty($sq1)) {
                    $sql1 .= ",money = CASE {$sq1} else money end ";
                }
                if (!empty($sql)) {
                    $sql = trim($sql, ',');
                    $sql = "update " . C("DB_PREFIX") . "lottery_ssc set {$sql}";
                    M()->execute($sql);
                }
                if (!empty($sql1)) {
                    $sql1 = trim($sql1, ',');
                    $sql1 = "update " . C("DB_PREFIX") . "Accountsinfo set {$sql1}";
                    M()->execute($sql1);
                }
                M("jiaoyi")->addAll($history_date8);
            }
        }
    }

	//每天插入新记录  1分钟1次
	public function add_days(){
		$q = M("lottery_class")->where("id = 1")->field("stime")->find();
		$s1 = strtotime(date("Y-m-d")." ".$q['stime']);
		$s99 = $s1 - 10*60;
		$s98 = $s1 - 5*60;
		$s4 = time();
		if($s4 > $s99 && $s4 < $s98){
			$res = M("jihua_jsk3")->field("issue")->select();
			$isf = self::deep_in_array(date("Ymd") . "001", $res);
			if(!$isf) {
				//开始第一期
				$dat1['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat2['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat3['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$numbers = range(5, 16);
				//shuffle 将数组顺序随即打乱
				shuffle($numbers);
				//array_slice 取该数组中的某一段
				$num = 5;
				$result = array_slice($numbers, 0, $num);
				$dat1['he'] = implode(",", $result);
				$input = array ("2","1");
				$rand_keys = array_rand ($input, 1);
				$dat2['size'] = $input[$rand_keys];
				$input2 = array ("1","2");
				$rand_keys2 = array_rand ($input2, 1);
				$dat3['attr'] = $input2[$rand_keys2];
				$dat1['status'] = "等待开奖";
				$dat2['status'] = "等待开奖";
				$dat3['status'] = "等待开奖";
				M("jihua_jsk3")->add($dat1);
				M("jihua_jsk3_size")->add($dat2);
				M("jihua_jsk3_attr")->add($dat3);
			}
		}
		$q2 = M("lottery_class")->where("id = 2")->field("stime")->find();
		$s2 = strtotime(date("Y-m-d")." ".$q2['stime']);
		$s97 = $s2 - 10*60;
		$s96 = $s2 - 5*60;
		if($s4 > $s97 && $s4 < $s96){
			$res2 = M("jihua_ahk3")->field("issue")->select();
			$isf2 = self::deep_in_array(date("Ymd") . "001", $res2);
			if(!$isf2) {
				//开始第一期
				$dat12['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat22['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat32['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$numbers2 = range(5, 16);
				//shuffle 将数组顺序随即打乱
				shuffle($numbers2);
				//array_slice 取该数组中的某一段
				$num2 = 5;
				$result2 = array_slice($numbers2, 0, $num2);
				$dat12['he'] = implode(",", $result2);
				$input2 = array ("2","1");
				$rand_keys2 = array_rand ($input2, 1);
				$dat22['size'] = $input2[$rand_keys2];
				$input22 = array ("1","2");
				$rand_keys22 = array_rand ($input22, 1);
				$dat32['attr'] = $input22[$rand_keys22];
				$nyi2 = explode("-",$dat12['issue']);
				$dat12['status'] = "等待开奖";
				$dat22['status'] = "等待开奖";
				$dat32['status'] = "等待开奖";
				M("jihua_ahk3")->add($dat12);
				M("jihua_ahk3_size")->add($dat22);
				M("jihua_ahk3_attr")->add($dat32);
			}
		}
		$q3 = M("lottery_class")->where("id = 3")->field("stime")->find();
		$s3 = strtotime(date("Y-m-d")." ".$q3['stime']);
		$s95 = $s3 - 10*60;
		$s94 = $s3 - 5*60;
		if($s4 > $s95 && $s4 < $s94){
			$res3 = M("jihua_gxk3")->field("issue")->select();
			$isf3 = self::deep_in_array(date("Ymd") . "001", $res3);
			if(!$isf3) {
				//开始第一期
				$dat13['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat23['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat33['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$numbers3 = range(5, 16);
				//shuffle 将数组顺序随即打乱
				shuffle($numbers3);
				//array_slice 取该数组中的某一段
				$num3 = 5;
				$result3 = array_slice($numbers3, 0, $num3);
				$dat13['he'] = implode(",", $result3);
				$input3 = array ("2","1");
				$rand_keys3 = array_rand ($input3, 1);
				$dat23['size'] = $input3[$rand_keys3];
				$input23 = array ("1","2");
				$rand_keys23 = array_rand ($input23, 1);
				$dat33['attr'] = $input23[$rand_keys23];
				$dat13['status'] = "等待开奖";
				$dat23['status'] = "等待开奖";
				$dat33['status'] = "等待开奖";
				M("jihua_gxk3")->add($dat13);
				M("jihua_gxk3_size")->add($dat23);
				M("jihua_gxk3_attr")->add($dat33);
			}
		}
		$q5 = M("lottery_class")->where("id = 4")->field("stime")->find();
		$s5 = strtotime(date("Y-m-d")." ".$q5['stime']);
		$s93 = $s5 - 10*60;
		$s92 = $s5 - 5*60;
		if($s4 > $s93 && $s4 < $s92){
			$res4 = M("jihua_hubk3")->field("issue")->select();
			$isf4 = self::deep_in_array(date("Ymd") . "001", $res4);
			if(!$isf4) {
				//开始第一期
				$dat14['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat24['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat34['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$numbers4 = range(5, 16);
				//shuffle 将数组顺序随即打乱
				shuffle($numbers4);
				//array_slice 取该数组中的某一段
				$num4 = 5;
				$result4 = array_slice($numbers4, 0, $num4);
				$dat14['he'] = implode(",", $result4);
				$input4 = array ("2","1");
				$rand_keys4 = array_rand ($input4, 1);
				$dat24['size'] = $input4[$rand_keys4];
				$input24 = array ("1","2");
				$rand_keys24 = array_rand ($input24, 1);
				$dat34['attr'] = $input24[$rand_keys24];
				$dat14['status'] = "等待开奖";
				$dat24['status'] = "等待开奖";
				$dat34['status'] = "等待开奖";
				M("jihua_hubk3")->add($dat14);
				M("jihua_hubk3_size")->add($dat24);
				M("jihua_hubk3_attr")->add($dat34);
			}
		}
		
		$q55 = M("lottery_class")->where("id = 5")->field("stime")->find();
		$s55 = strtotime(date("Y-m-d")." ".$q55['stime']);
		$s91 = $s5 - 10*60;
		$s90 = $s5 - 5*60;
		if($s4 > $s91 && $s4 < $s90){
			$bjg = $this->get_data("bjk3");
			if(substr($bjg[0]['expect'],0,1)=='0'){
				$e = '0'.($bjg[0]['expect']+2);
			}else{
				$e = $bjg[0]['expect']+2;
			}
			$res5 = M("jihua_bjk3")->order("id desc")->find();
			if($res5){
				if(strpos($res5['issue'],"-")){
					$nar5 = explode("-",$res5['issue']);
					$new5 = array();
					for($i = $nar5[0];$i<=$nar5[1];$i++){
						if($i!=$nar5[0]){
							$new5[] = '0'.$i;
						}else{
							$new5[] = $i;
						}
					}
				}else{
					$new5[] = trim($res5['issue']);
				}
			}
			if(!in_array($bjg[0]['expect'],$new5)) {
				//开始第一期
				$dat15['issue'] = $bjg[0]['expect'] . "-" . $e;
				$dat25['issue'] = $bjg[0]['expect'] . "-" . $e;
				$dat35['issue'] = $bjg[0]['expect'] . "-" . $e;
				$numbers5 = range(5, 16);
				//shuffle 将数组顺序随即打乱
				shuffle($numbers5);
				//array_slice 取该数组中的某一段
				$num5 = 5;
				$result5 = array_slice($numbers5, 0, $num5);
				$dat15['he'] = implode(",", $result5);
				$input5 = array ("2","1");
				$rand_keys5 = array_rand ($input5, 1);
				$dat25['size'] = $input5[$rand_keys5];
				$input25 = array ("1","2");
				$rand_keys25 = array_rand ($input25, 1);
				$dat35['attr'] = $input25[$rand_keys25];
				$dat15['status'] = "等待开奖";
				$dat25['status'] = "等待开奖";
				$dat35['status'] = "等待开奖";
				M("jihua_bjk3")->add($dat15);
				M("jihua_bjk3_size")->add($dat25);
				M("jihua_bjk3_attr")->add($dat35);
			}
		}
		
		$q9 = M("lottery_class")->where("id = 9")->field("stime")->find();
		$s9 = strtotime(date("Y-m-d")." ".$q9['stime']);
		$s89 = $s9 - 10*60;
		$s88 = $s9 - 5*60;
		if($s4 > $s89 && $s4 < $s88){
			$res6 = M("jihua_hebk3")->field("issue")->select();
			$isf6 = self::deep_in_array(date("Ymd") . "001", $res6);
			if(!$isf6) {
				//开始第一期
				$dat16['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat26['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat36['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$numbers6 = range(5, 16);
				//shuffle 将数组顺序随即打乱
				shuffle($numbers6);
				//array_slice 取该数组中的某一段
				$num6 = 5;
				$result6 = array_slice($numbers6, 0, $num6);
				$dat16['he'] = implode(",", $result6);
				$input6 = array ("2","1");
				$rand_keys6 = array_rand ($input6, 1);
				$dat26['size'] = $input6[$rand_keys6];
				$input26 = array ("1","2");
				$rand_keys26 = array_rand ($input26, 1);
				$dat36['attr'] = $input26[$rand_keys26];
				$dat16['status'] = "等待开奖";
				$dat26['status'] = "等待开奖";
				$dat36['status'] = "等待开奖";
				M("jihua_hebk3")->add($dat16);
				M("jihua_hebk3_size")->add($dat26);
				M("jihua_hebk3_attr")->add($dat36);
			}
		}
		$q10 = M("lottery_class")->where("id = 10")->field("stime")->find();
		$s10 = strtotime(date("Y-m-d")." ".$q10['stime']);
		$s87 = $s10 - 10*60;
		$s86 = $s10 - 5*60;
		if($s4 > $s87 && $s4 < $s86){
			$res7 = M("jihua_gsk3")->field("issue")->select();
			$isf7 = self::deep_in_array(date("Ymd") . "001", $res7);
			if(!$isf7) {
				//开始第一期
				$dat17['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat27['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat37['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$numbers7 = range(5, 16);
				//shuffle 将数组顺序随即打乱
				shuffle($numbers7);
				//array_slice 取该数组中的某一段
				$num7 = 5;
				$result7 = array_slice($numbers7, 0, $num7);
				$dat17['he'] = implode(",", $result7);
				$input7 = array ("2","1");
				$rand_keys7 = array_rand ($input7, 1);
				$dat27['size'] = $input7[$rand_keys7];
				$input27 = array ("1","2");
				$rand_keys27 = array_rand ($input27, 1);
				$dat37['attr'] = $input27[$rand_keys27];
				$dat17['status'] = "等待开奖";
				$dat27['status'] = "等待开奖";
				$dat37['status'] = "等待开奖";
				M("jihua_gsk3")->add($dat17);
				M("jihua_gsk3_size")->add($dat27);
				M("jihua_gsk3_attr")->add($dat37);
			}
		}
		$q11 = M("lottery_class")->where("id = 11")->field("stime")->find();
		$s11 = strtotime(date("Y-m-d")." ".$q11['stime']);
		$s85 = $s11 - 10*60;
		$s84 = $s11 - 5*60;
		if($s4 > $s85 && $s4 < $s84){
			$res8 = M("jihua_shk3")->field("issue")->select();
			$isf8 = self::deep_in_array(date("Ymd") . "001", $res8);
			if(!$isf8) {
				//开始第一期
				$dat18['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat28['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat38['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$numbers8 = range(5, 16);
				//shuffle 将数组顺序随即打乱
				shuffle($numbers8);
				//array_slice 取该数组中的某一段
				$num8 = 5;
				$result8 = array_slice($numbers8, 0, $num8);
				$dat18['he'] = implode(",", $result8);
				$input8 = array ("2","1");
				$rand_keys8 = array_rand ($input8, 1);
				$dat28['size'] = $input8[$rand_keys8];
				$input28 = array ("1","2");
				$rand_keys28 = array_rand ($input28, 1);
				$dat38['attr'] = $input28[$rand_keys28];
				$dat18['status'] = "等待开奖";
				$dat28['status'] = "等待开奖";
				$dat38['status'] = "等待开奖";
				M("jihua_shk3")->add($dat18);
				M("jihua_shk3_size")->add($dat28);
				M("jihua_shk3_attr")->add($dat38);
			}
		}
		$q12 = M("lottery_class")->where("id = 12")->field("stime")->find();
		$s12 = strtotime(date("Y-m-d")." ".$q12['stime']);
		$s83 = $s12 - 10*60;
		$s82 = $s12 - 5*60;
		if($s4 > $s83 && $s4 < $s82){
			$res9 = M("jihua_gzk3")->field("issue")->select();
			$isf9 = self::deep_in_array(date("Ymd") . "001", $res9);
			if(!$isf9) {
				//开始第一期
				$dat19['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat29['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat39['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$numbers9 = range(5, 16);
				//shuffle 将数组顺序随即打乱
				shuffle($numbers9);
				//array_slice 取该数组中的某一段
				$num9 = 5;
				$result9 = array_slice($numbers9, 0, $num9);
				$dat19['he'] = implode(",", $result9);
				$input9 = array ("2","1");
				$rand_keys9 = array_rand ($input9, 1);
				$dat29['size'] = $input9[$rand_keys9];
				$input29 = array ("1","2");
				$rand_keys29 = array_rand ($input29, 1);
				$dat39['attr'] = $input29[$rand_keys29];
				$dat19['status'] = "等待开奖";
				$dat29['status'] = "等待开奖";
				$dat39['status'] = "等待开奖";
				M("jihua_gzk3")->add($dat19);
				M("jihua_gzk3_size")->add($dat29);
				M("jihua_gzk3_attr")->add($dat39);
			}
		}
		$q13 = M("lottery_class")->where("id = 13")->field("stime")->find();
		$s13 = strtotime(date("Y-m-d")." ".$q13['stime']);
		$s81 = $s13 - 10*60;
		$s80 = $s13 - 5*60;
		if($s4 > $s81 && $s4 < $s80){
			$res10 = M("jihua_jlk3")->field("issue")->select();
			$isf10 = self::deep_in_array(date("Ymd") . "001", $res10);
			if(!$isf10) {
				//开始第一期
				$dat110['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat210['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat310['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$numbers10 = range(5, 16);
				//shuffle 将数组顺序随即打乱
				shuffle($numbers10);
				//array_slice 取该数组中的某一段
				$num10 = 5;
				$result10 = array_slice($numbers10, 0, $num10);
				$dat110['he'] = implode(",", $result10);
				$input10 = array ("2","1");
				$rand_keys10 = array_rand ($input10, 1);
				$dat210['size'] = $input10[$rand_keys10];
				$input210 = array ("1","2");
				$rand_keys210 = array_rand ($input210, 1);
				$dat310['attr'] = $input210[$rand_keys210];
				$dat110['status'] = "等待开奖";
				$dat210['status'] = "等待开奖";
				$dat310['status'] = "等待开奖";
				M("jihua_jlk3")->add($dat110);
				M("jihua_jlk3_size")->add($dat210);
				M("jihua_jlk3_attr")->add($dat310);
			}
		}

		$q56 = M("lottery_class")->where("id = 21")->field("stime")->find();
		$s56 = strtotime(date("Y-m-d")." ".$q56['stime']);
		$s68 = $s56 - 10*60;
		$s67 = $s56 - 5*60;
		if($s4 > $s68 && $s4 < $s67){
			$bjg1 = $this->get_data("bjpk10");
			$e1 = $bjg1[0]['expect']+2;
			$res51 = M("jihua_pk10")->order("id desc")->find();
			if($res51){
				if(strpos($res51['issue'],"-")){
					$nar51 = explode("-",$res51['issue']);
					$new51 = array();
					for($i = $nar51[0];$i<=$nar51[1];$i++){			
						$new51[] = $i;
					}
				}else{
					$new51[] = trim($res51['issue']);
				}
			}
			if(!in_array($bjg1[0]['expect'],$new51)) {
				//开始第一期
				$dat95['issue'] = $bjg[0]['expect'] . "-" . $e;
				$numbers51 = range(5, 16);
				//shuffle 将数组顺序随即打乱
				shuffle($numbers51);
				//array_slice 取该数组中的某一段
				$num51 = 5;
				$result51 = array_slice($numbers51, 0, $num51);
				$dat95['he'] = implode(",", $result51);
				$dat95['status'] = "等待开奖";
				$dat95['is_start'] = 1;
				M("jihua_pk10")->add($dat95);
			}
		}
		//重庆时时彩
		$qc = M("lottery_class")->where("id = 15")->field("stime")->find();
		$s5c = strtotime(date("Y-m-d")." 10:00");
		$s66 = $s5c - 10*60;
		$s65 = $s5c - 5*60;
		if($s4 > $s66 && $s4 < $s65){
			$res44 = M("jihua_ssc_gw")->field("issue")->select();
			$isf44 = self::deep_in_array(date("Ymd") . "001", $res44);
			if(!$isf44) {
				//开始第一期
				$dat14['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat24['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat34['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat44['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat54['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";	
				$numbers4 = range(0, 9);
				//shuffle 将数组顺序随即打乱
				shuffle($numbers4);
				//array_slice 取该数组中的某一段
				$num4 = 5;
				$result4 = array_slice($numbers4, 0, $num4);
				$dat14['he'] = implode(",", $result4);
				$input24 = array ("0","1","2","3","4","5","6","7","8","9");
				$rand_keys24 = array_rand ($input24, 5);
				$dat24['he'] = implode(",",$rand_keys24);
				$input34 = array ("0","1","2","3","4","5","6","7","8","9");
				$rand_keys34 = array_rand ($input34, 5);
				$dat34['he'] = implode(",",$rand_keys34);
				$input44 = array ("0","1","2","3","4","5","6","7","8","9");
				$rand_keys44 = array_rand ($input44, 5);
				$dat44['he'] = implode(",",$rand_keys44);
				$input54 = array ("0","1","2","3","4","5","6","7","8","9");
				$rand_keys54 = array_rand ($input54, 5);
				$dat54['he'] = implode(",",$rand_keys54);
				$dat14['status'] = "等待开奖";
				$dat24['status'] = "等待开奖";
				$dat34['status'] = "等待开奖";
				$dat44['status'] = "等待开奖";
				$dat54['status'] = "等待开奖";
				M("jihua_ssc_gw")->add($dat14);
				M("jihua_ssc_sw")->add($dat24);
				M("jihua_ssc_bw")->add($dat34);
				M("jihua_ssc_qw")->add($dat44);
				M("jihua_ssc_ww")->add($dat54);
			}
		}
		//新疆时时彩
		$xj = M("lottery_class")->where("id = 17")->field("stime")->find();
		$s5x = strtotime(date("Y-m-d")." ".$xj['stime']);
		$s64 = $s5x - 10*60;
		$s63 = $s5x - 5*60;
		if($s4 > $s64 && $s4 < $s63){
			$res444 = M("jihua_xjssc_gw")->field("issue")->select();
			$isf444 = self::deep_in_array(date("Ymd") . "001", $res444);
			if(!$isf444) {
				//开始第一期
				$dat144['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat244['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat344['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat444['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat544['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";	
				$numbers44 = range(0, 9);
				//shuffle 将数组顺序随即打乱
				shuffle($numbers44);
				//array_slice 取该数组中的某一段
				$num44 = 5;
				$result44 = array_slice($numbers44, 0, $num44);
				$dat144['he'] = implode(",", $result44);
				$input244 = array ("0","1","2","3","4","5","6","7","8","9");
				$rand_keys244 = array_rand ($input244, 5);
				$dat244['he'] = implode(",",$rand_keys244);
				$input344 = array ("0","1","2","3","4","5","6","7","8","9");
				$rand_keys344 = array_rand ($input344, 5);
				$dat344['he'] = implode(",",$rand_keys34);
				$input444 = array ("0","1","2","3","4","5","6","7","8","9");
				$rand_keys444 = array_rand ($input444, 5);
				$dat444['he'] = implode(",",$rand_keys444);
				$input544 = array ("0","1","2","3","4","5","6","7","8","9");
				$rand_keys544 = array_rand ($input544, 5);
				$dat544['he'] = implode(",",$rand_keys544);
				$dat144['status'] = "等待开奖";
				$dat244['status'] = "等待开奖";
				$dat344['status'] = "等待开奖";
				$dat444['status'] = "等待开奖";
				$dat544['status'] = "等待开奖";
				M("jihua_xjssc_gw")->add($dat144);
				M("jihua_xjssc_sw")->add($dat244);
				M("jihua_xjssc_bw")->add($dat344);
				M("jihua_xjssc_qw")->add($dat444);
				M("jihua_xjssc_ww")->add($dat544);
			}
		}
		
		//天津时时彩
		$tj = M("lottery_class")->where("id = 18")->field("stime")->find();
		$s5xt = strtotime(date("Y-m-d")." ".$tj['stime']);
		$s62 = $s5xt - 10*60;
		$s61 = $s5xt - 5*60;
		if($s4 > $s62 && $s4 < $s61){
			$res4444 = M("jihua_tjssc_gw")->field("issue")->select();
			$isf4444 = self::deep_in_array(date("Ymd") . "001", $res4444);
			if(!$isf4444) {
				//开始第一期
				$dat1444['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat2444['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat3444['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat4444['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
				$dat5444['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";	
				$numbers444 = range(0, 9);
				//shuffle 将数组顺序随即打乱
				shuffle($numbers444);
				//array_slice 取该数组中的某一段
				$num444 = 5;
				$result444 = array_slice($numbers444, 0, $num444);
				$dat1444['he'] = implode(",", $result444);
				$input2444 = array ("0","1","2","3","4","5","6","7","8","9");
				$rand_keys2444 = array_rand ($input2444, 5);
				$dat2444['he'] = implode(",",$rand_keys2444);
				$input3444 = array ("0","1","2","3","4","5","6","7","8","9");
				$rand_keys3444 = array_rand ($input3444, 5);
				$dat3444['he'] = implode(",",$rand_keys344);
				$input4444 = array ("0","1","2","3","4","5","6","7","8","9");
				$rand_keys4444 = array_rand ($input4444, 5);
				$dat4444['he'] = implode(",",$rand_keys4444);
				$input5444 = array ("0","1","2","3","4","5","6","7","8","9");
				$rand_keys5444 = array_rand ($input5444, 5);
				$dat5444['he'] = implode(",",$rand_keys5444);
				$dat1444['status'] = "等待开奖";
				$dat2444['status'] = "等待开奖";
				$dat3444['status'] = "等待开奖";
				$dat4444['status'] = "等待开奖";
				$dat5444['status'] = "等待开奖";
				M("jihua_tjssc_gw")->add($dat1444);
				M("jihua_tjssc_sw")->add($dat2444);
				M("jihua_tjssc_bw")->add($dat3444);
				M("jihua_tjssc_qw")->add($dat4444);
				M("jihua_tjssc_ww")->add($dat5444);
			}
		}
		//埃及二分彩
		$res676 = M("jihua_ajssc_gw")->field("issue")->select();
		$isf676 = self::deep_in_array(date("Ymd") . "001", $res676);
		if(!$isf676) {
			//开始第一期
			$dat1676['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
			$dat2676['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
			$dat3676['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
			$dat4676['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";
			$dat5676['issue'] = date("Ymd") . "001" . "-" . date("Ymd") . "003";	
			$numbers676 = range(0, 9);
			//shuffle 将数组顺序随即打乱
			shuffle($numbers676);
			//array_slice 取该数组中的某一段
			$num676 = 5;
			$result676 = array_slice($numbers676, 0, $num676);
			$dat1676['he'] = implode(",", $result676);
			$input2676 = array ("0","1","2","3","4","5","6","7","8","9");
			$rand_keys2676 = array_rand ($input2676, 5);
			$dat2676['he'] = implode(",",$rand_keys2676);
			$input3676 = array ("0","1","2","3","4","5","6","7","8","9");
			$rand_keys3676 = array_rand ($input3676, 5);
			$dat3676['he'] = implode(",",$rand_keys3676);
			$input4676 = array ("0","1","2","3","4","5","6","7","8","9");
			$rand_keys4676 = array_rand ($input4676, 5);
			$dat4676['he'] = implode(",",$rand_keys4676);
			$input5676 = array ("0","1","2","3","4","5","6","7","8","9");
			$rand_keys5676 = array_rand ($input5676, 5);
			$dat5676['he'] = implode(",",$rand_keys5676);
			$dat1676['status'] = "等待开奖";
			$dat2676['status'] = "等待开奖";
			$dat3676['status'] = "等待开奖";
			$dat4676['status'] = "等待开奖";
			$dat5676['status'] = "等待开奖";
			M("jihua_ajssc_gw")->add($dat1676);
			M("jihua_ajssc_sw")->add($dat2676);
			M("jihua_ajssc_bw")->add($dat3676);
			M("jihua_ajssc_qw")->add($dat4676);
			M("jihua_ajssc_ww")->add($dat5676);
		}
	}
    //1分钟1次 安徽快3追号判断
    public function jihua_ahk3()
    {
        //安徽快3
        $arr2 = $this->get_data("ahk3");
        $res3 = M("jihua_ahk3")->where("is_do = 0")->find();
        $bs = 0;
        $is_z = 0;
        if ($res3) {
            if (strpos($res3['issue'], "-")) {
                $nar3 = explode("-", $res3['issue']);
                $new3 = array();
                for ($i = $nar3[0]; $i <= $nar3[1]; $i++) {
                    $new3[] = $i;
                }
            } else {
                $new3[] = trim($res3['issue']);
            }
            $co3 = count($new3);
            foreach ($new3 as $k3 => $v3) {
                $sta3 = array();
                if ($v3 == $arr2[0]['expect']) {
                    $hs3 = explode(",", rtrim($res3['he']));
                    if (in_array($arr2[0]['total'], $hs3)) {
                        $is_z = 1;
                        $bs = $k3;
                        break;
                    } else {
                        $is_z = 2;
                        $bs = $k3;
                        break;
                    }
                }
            }
            //处理
            if ($is_z == 1) {
                if ($bs == 0) {
                    $cc3 = "当前中出";
                } else if ($bs == 1) {
                    $cc3 = "2期中出";
                } else {
                    $cc3 = "3期中出";
                }
                M("jihua_ahk3")->where("id = '{$res3['id']}'")->save(array("status" => $cc3, "is_do" => 1));
                $start3 = $new3[$bs] + 1;
                $mid3 = $new3[$bs] + 2;
                $end3 = $new3[$bs] + 3;
                $di3 = date("Ymd") . "080";
                if ($new3[$bs] != $di3) {
                    if ($start3 <= $di3) {
                        if ($end3 > $di3) {
                            if ($mid3 > $di3) {
                                $dat13['issue'] = $start3;
                            } else {
                                $dat13['issue'] = $start3 . "-" . $mid3;
                            }
                        } else {
                            $dat13['issue'] = $start3 . "-" . $end3;
                        }
                        $numbers3 = range(5, 16);
                        //shuffle 将数组顺序随即打乱
                        shuffle($numbers3);
                        //array_slice 取该数组中的某一段
                        $num3 = 5;
                        $result3 = array_slice($numbers3, 0, $num3);
                        $dat13['he'] = implode(",", $result3);
                        $dat13['status'] = "等待开奖";
                        M("jihua_ahk3")->add($dat13);
                    }
                }
            } else if ($is_z == 2) {
                if ($bs == 0) {
                    $cc4 = "等待开奖";
                } else if ($bs == 1) {
                    $cc4 = "等待开奖";
                } else {
                    $cc4 = "追号失败";
                }
                M("jihua_ahk3")->where("id = '{$res3['id']}'")->save(array("status" => $cc4));
                if ($bs == $co3 - 1) {
                    M("jihua_ahk3")->where("id = '{$res3['id']}'")->save(array("status" => $cc4, "is_do" => 1));
                    $start4 = $new3[$bs] + 1;
                    $mid4 = $new3[$bs] + 2;
                    $end4 = $new3[$bs] + 3;
                    $di4 = date("Ymd") . "080";
                    if ($new3[$bs] != $di4) {
                        if ($start4 <= $di4) {
                            if ($end4 > $di4) {
                                if ($mid4 > $di4) {
                                    $dat14['issue'] = $start4;
                                } else {
                                    $dat14['issue'] = $start4 . "-" . $mid4;
                                }
                            } else {
                                $dat14['issue'] = $start4 . "-" . $end4;
                            }
                            $numbers4 = range(5, 16);
                            //shuffle 将数组顺序随即打乱
                            shuffle($numbers4);
                            //array_slice 取该数组中的某一段
                            $num4 = 5;
                            $result4 = array_slice($numbers4, 0, $num4);
                            $dat14['he'] = implode(",", $result4);
                            $dat14['status'] = "等待开奖";
                            M("jihua_ahk3")->add($dat14);
                        }
                    }
                }
            }
        }
        $bs = 0;
        $is_z = 0;
        //--------------------------大小-------------------------------------------
        $res4 = M("jihua_ahk3_size")->where("is_do = 0")->find();
        if ($res4) {
            if (strpos($res4['issue'], "-")) {
                $nar4 = explode("-", $res4['issue']);
                $new4 = array();
                for ($i = $nar4[0]; $i <= $nar4[1]; $i++) {
                    $new4[] = $i;
                }
            } else {
                $new4[] = trim($res4['issue']);
            }
            $co4 = count($new4);
            foreach ($new4 as $k4 => $v4) {
                $sta4 = array();
                if ($v4 == $arr2[0]['expect']) {
                    if ($arr2[0]['size'] == trim($res4['size'])) {
                        $is_z = 1;
                        $bs = $k4;
                        break;
                    } else {
                        $is_z = 2;
                        $bs = $k4;
                        break;
                    }
                }
            }
            if ($is_z == 1) {
                if ($bs == 0) {
                    $cc4 = "当前中出";
                } else if ($bs == 1) {
                    $cc4 = "2期中出";
                } else {
                    $cc4 = "3期中出";
                }
                M("jihua_ahk3_size")->where("id = '{$res4['id']}'")->save(array("status" => $cc4, "is_do" => 1));
                $start14 = $new4[$bs] + 1;
                $mid14 = $new4[$bs] + 2;
                $end14 = $new4[$bs] + 3;
                $di14 = date("Ymd") . "080";
                if ($new4[$bs] != $di14) {
                    if ($start14 <= $di14) {
                        if ($end14 > $di14) {
                            if ($mid14 > $di14) {
                                $dat14['issue'] = $start14;
                            } else {
                                $dat14['issue'] = $start14 . "-" . $mid14;
                            }
                        } else {
                            $dat14['issue'] = $start14 . "-" . $end14;
                        }
                        $input4 = array("2", "1");
                        $rand_keys4 = array_rand($input4, 1);
                        $dat14['size'] = $input4[$rand_keys4];
                        $dat14['status'] = "等待开奖";
                        M("jihua_ahk3_size")->add($dat14);
                    }
                }
            } else if ($is_z == 2) {
                if ($bs == 0) {
                    $cc4 = "等待开奖";
                } else if ($bs == 1) {
                    $cc4 = "等待开奖";
                } else {
                    $cc4 = "追号失败";
                }
                M("jihua_ahk3_size")->where("id = '{$res4['id']}'")->save(array("status" => $cc4));
                if ($bs == $co4 - 1) {
                    M("jihua_ahk3_size")->where("id = '{$res4['id']}'")->save(array("status" => $cc4, "is_do" => 1));
                    $start14 = $new4[$bs] + 1;
                    $mid14 = $new4[$bs] + 2;
                    $end14 = $new4[$bs] + 3;
                    $di14 = date("Ymd") . "080";
                    if ($new4[$bs] != $di14) {
                        if ($start14 <= $di14) {
                            if ($end14 > $di14) {
                                if ($mid14 > $di14) {
                                    $dat14['issue'] = $start14;
                                } else {
                                    $dat14['issue'] = $start14 . "-" . $mid14;
                                }
                            } else {
                                $dat14['issue'] = $start14 . "-" . $end14;
                            }
                            $input4 = array("2", "1");
                            $rand_keys4 = array_rand($input4, 1);
                            $dat14['size'] = $input4[$rand_keys4];
                            $dat14['status'] = "等待开奖";
                            M("jihua_ahk3_size")->add($dat14);
                        }
                    }
                }
            }
        }
        $bs = 0;
        $is_z = 0;
        //-------------------------单双-------------------------------------------------------
        $res5 = M("jihua_ahk3_attr")->where("is_do = 0")->find();
        if ($res5) {
            if (strpos($res5['issue'], "-")) {
                $nar5 = explode("-", $res5['issue']);
                $new5 = array();
                for ($i = $nar5[0]; $i <= $nar5[1]; $i++) {
                    $new5[] = $i;
                }
            } else {
                $new5[] = trim($res5['issue']);
            }
            $co5 = count($new5);
            foreach ($new5 as $k5 => $v5) {
                $sta5 = array();
                if ($v5 == $arr2[0]['expect']) {
                    if ($arr2[0]['attr'] == trim($res5['attr'])) {
                        $is_z = 1;
                        $bs = $k5;
                        break;
                    } else {
                        $is_z = 2;
                        $bs = $k5;
                        break;
                    }
                }
            }
            if ($is_z == 1) {
                if ($bs == 0) {
                    $cc5 = "当前中出";
                } else if ($bs == 1) {
                    $cc5 = "2期中出";
                } else {
                    $cc5 = "3期中出";
                }
                M("jihua_ahk3_attr")->where("id = '{$res5['id']}'")->save(array("status" => $cc5, "is_do" => 1));
                $start25 = $new5[$bs] + 1;
                $mid25 = $new5[$bs] + 2;
                $end25 = $new5[$bs] + 3;
                $di25 = date("Ymd") . "080";
                if ($new5[$bs] != $di25) {
                    if ($start25 <= $di25) {
                        if ($end25 > $di25) {
                            if ($mid25 > $di25) {
                                $dat25['issue'] = $start25;
                            } else {
                                $dat25['issue'] = $start25 . "-" . $mid25;
                            }
                        } else {
                            $dat25['issue'] = $start25 . "-" . $end25;
                        }
                        $input5 = array("1", "2");
                        $rand_keys5 = array_rand($input5, 1);
                        $dat25['attr'] = $input5[$rand_keys5];
                        $dat25['status'] = "等待开奖";
                        M("jihua_ahk3_attr")->add($dat25);
                    }
                }
            } else if ($is_z == 2) {
                if ($bs == 0) {
                    $cc5 = "等待开奖";
                } else if ($bs == 1) {
                    $cc5 = "等待开奖";
                } else {
                    $cc5 = "追号失败";
                }
                M("jihua_ahk3_attr")->where("id = '{$res5['id']}'")->save(array("status" => $cc5));
                if ($bs == $co5 - 1) {
                    M("jihua_ahk3_attr")->where("id = '{$res5['id']}'")->save(array("status" => $cc5, "is_do" => 1));
                    $start25 = $new5[$bs] + 1;
                    $mid25 = $new5[$bs] + 2;
                    $end25 = $new5[$bs] + 3;
                    $di25 = date("Ymd") . "080";
                    if ($new5[$bs] != $di25) {
                        if ($start25 <= $di25) {
                            if ($end25 > $di25) {
                                if ($mid25 > $di25) {
                                    $dat25['issue'] = $start25;
                                } else {
                                    $dat25['issue'] = $start25 . "-" . $mid25;
                                }
                            } else {
                                $dat25['issue'] = $start25 . "-" . $end25;
                            }
                            $input5 = array("1", "2");
                            $rand_keys5 = array_rand($input5, 1);
                            $dat25['attr'] = $input5[$rand_keys5];
                            $dat25['status'] = "等待开奖";
                            M("jihua_ahk3_attr")->add($dat25);
                        }
                    }
                }
            }
        }
    }
    //江苏快3追号判断  1分钟1次
	public function jihua_jsk3(){
		//江苏快3
		$arr = $this->get_data("jsk3");
		$res = M("jihua_jsk3")->where("is_do = 0")->find();
		$bs = 0;
		$is_z = 0;
		if($res){
			if(strpos($res['issue'],"-")){
				$nar = explode("-",$res['issue']);
				$new = array();
				for($i = $nar[0];$i<=$nar[1];$i++){
					$new[] = $i;
				}
			}else{
				$new[] = trim($res['issue']);
			}
			$co = count($new);
			foreach($new as $k=>$v){
				$sta = array();
				if($v == $arr[0]['expect']){
					$hs = explode(",",rtrim($res['he']));
					if(in_array($arr[0]['total'],$hs)){
						$is_z = 1;
						$bs = $k;
						break;
					}else{
						$is_z = 2;
						$bs = $k;
						break;
					}
				}
			}
			//处理
			if($is_z == 1){
				if($bs==0){
					$cc = "当前中出";
				}else if($bs==1){
					$cc = "2期中出";
				}else{
					$cc = "3期中出";
				}
				M("jihua_jsk3")->where("id = '{$res['id']}'")->save(array("status"=>$cc,"is_do"=>1));
				$start = $new[$bs]+1;
				$mid = $new[$bs]+2;
				$end = $new[$bs]+3;
				$di = date("Ymd")."082";
				if($new[$bs]!=$di){
					if($start <= $di){
						if($end > $di){
							if($mid > $di){
								$dat1['issue'] = $start;
							}else{
								$dat1['issue'] = $start."-".$mid;
							}
						}else{
							$dat1['issue'] = $start."-".$end;
						}
						$numbers = range(5, 16);
						//shuffle 将数组顺序随即打乱
						shuffle($numbers);
						//array_slice 取该数组中的某一段
						$num = 5;
						$result = array_slice($numbers, 0, $num);
						$dat1['he'] = implode(",", $result);
						$dat1['status'] = "等待开奖";
						M("jihua_jsk3")->add($dat1);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc = "等待开奖";
				}else if($bs==1){
					$cc = "等待开奖";
				}else{
					$cc = "追号失败";
				}
				M("jihua_jsk3")->where("id = '{$res['id']}'")->save(array("status"=>$cc));
				if($bs==$co-1){
					M("jihua_jsk3")->where("id = '{$res['id']}'")->save(array("status"=>$cc,"is_do"=>1));	
					$start = $new[$bs]+1;
					$mid = $new[$bs]+2;
					$end = $new[$bs]+3;
					$di = date("Ymd")."082";
					if($new[$bs]!=$di){
						if($start <= $di){
							if($end > $di){
								if($mid > $di){
									$dat1['issue'] = $start;
								}else{
									$dat1['issue'] = $start."-".$mid;
								}
							}else{
								$dat1['issue'] = $start."-".$end;
							}
							$numbers = range(5, 16);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers);
							//array_slice 取该数组中的某一段
							$num = 5;
							$result = array_slice($numbers, 0, $num);
							$dat1['he'] = implode(",", $result);
							$dat1['status'] = "等待开奖";
							M("jihua_jsk3")->add($dat1);
						}	
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//--------------------------大小-------------------------------------------
		$res1 = M("jihua_jsk3_size")->where("is_do = 0")->find();
		if($res1){
			if(strpos($res1['issue'],"-")){
				$nar1 = explode("-",$res1['issue']);
				$new1 = array();
				for($i = $nar1[0];$i<=$nar1[1];$i++){
					$new1[] = $i;
				}
			}else{
				$new1[] = trim($res1['issue']);
			}
			$co1 = count($new1);
			foreach($new1 as $k1=>$v1){
				$sta1 = array();
				if($v1 == $arr[0]['expect']){
					if($arr[0]['size'] == trim($res1['size'])){
						$is_z = 1;
						$bs = $k1;
						break;
					}else{
						$is_z = 2;
						$bs = $k1;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$cc1 = "当前中出";
				}else if($bs==1){
					$cc1 = "2期中出";
				}else{
					$cc1 = "3期中出";
				}
				M("jihua_jsk3_size")->where("id = '{$res1['id']}'")->save(array("status"=>$cc1,"is_do"=>1));
				$start1 = $new1[$bs]+1;
				$mid1 = $new1[$bs]+2;
				$end1 = $new1[$bs]+3;
				$di1 = date("Ymd")."082";
				if($new1[$bs]!=$di1){
					if($start1 <= $di1){
						if($end1 > $di1){
							if($mid1 > $di1){
								$dat2['issue'] = $start1;
							}else{
								$dat2['issue'] = $start1."-".$mid1;
							}
						}else{
							$dat2['issue'] = $start1."-".$end1;
						}
						$input = array ("2","1");
						$rand_keys = array_rand ($input, 1);
						$dat2['size'] = $input[$rand_keys];
						$dat2['status'] = "等待开奖";
						M("jihua_jsk3_size")->add($dat2);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc1 = "等待开奖";
				}else if($bs==1){
					$cc1 = "等待开奖";
				}else{
					$cc1 = "追号失败";
				}
				M("jihua_jsk3_size")->where("id = '{$res1['id']}'")->save(array("status"=>$cc1));
				if($bs==$co1-1){
					M("jihua_jsk3_size")->where("id = '{$res1['id']}'")->save(array("status"=>$cc1,"is_do"=>1));
					$start1 = $new1[$bs]+1;
					$mid1 = $new1[$bs]+2;
					$end1 = $new1[$bs]+3;
					$di1 = date("Ymd") . "082";
					if($new1[$bs]!=$di1){
						if($start1 <= $di1){
							if($end1 > $di1){
								if($mid1 > $di1){
									$dat2['issue'] = $start1;
								}else{
									$dat2['issue'] = $start1."-".$mid1;
								}
							}else{
								$dat2['issue'] = $start1."-".$end1;
							}
							$input = array ("2","1");
							$rand_keys = array_rand ($input, 1);
							$dat2['size'] = $input[$rand_keys];
							$dat2['status'] = "等待开奖";
							M("jihua_jsk3_size")->add($dat2);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//-------------------------单双-------------------------------------------------------
		$res2 = M("jihua_jsk3_attr")->where("is_do = 0")->find();
		if($res2){
			if(strpos($res2['issue'],"-")){
				$nar2 = explode("-",$res2['issue']);
				$new2 = array();
				for($i = $nar2[0];$i<=$nar2[1];$i++){
					$new2[] = $i;
				}
			}else{
				$new2[] = trim($res2['issue']);
			}
			$co2 = count($new2);
			foreach($new2 as $k2=>$v2){
				$sta2 = array();
				if($v2 == $arr[0]['expect']){
					if($arr[0]['attr'] == trim($res2['attr'])){
						$is_z = 1;
						$bs = $k2;
						break;
					}else{
						$is_z = 2;
						$bs = $k;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$cc2 = "当前中出";
				}else if($bs==1){
					$cc2 = "2期中出";
				}else{
					$cc2 = "3期中出";
				}
				M("jihua_jsk3_attr")->where("id = '{$res2['id']}'")->save(array("status"=>$cc2,"is_do"=>1));
				$start2 = $new2[$bs]+1;
				$mid2 = $new2[$bs]+2;
				$end2 = $new2[$bs]+3;
				$di2 = date("Ymd")."082";
				if($new2[$bs]!=$di2){
					if($start2 <= $di2){
						if($end2 > $di2){
							if($mid2 > $di2){
								$dat3['issue'] = $start2;
							}else{
								$dat3['issue'] = $start2."-".$mid2;
							}
						}else{
							$dat3['issue'] = $start2."-".$end2;
						}
						$input = array ("1","2");
						$rand_keys = array_rand ($input, 1);
						$dat3['attr'] = $input[$rand_keys];
						$dat3['status'] = "等待开奖";
						M("jihua_jsk3_attr")->add($dat3);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc2 = "等待开奖";
				}else if($bs==1){
					$cc2 = "等待开奖";
				}else{
					$cc2 = "追号失败";
				}
				M("jihua_jsk3_attr")->where("id = '{$res2['id']}'")->save(array("status"=>$cc2));
				if($bs==$co2-1){
					M("jihua_jsk3_attr")->where("id = '{$res2['id']}'")->save(array("status"=>$cc2,"is_do"=>1));
					$start2 = $new2[$bs]+1;
					$mid2 = $new2[$bs]+2;
					$end2 = $new2[$bs]+3;
					$di2 = date("Ymd")."082";
					if($new2[$bs]!=$di2){
						if($start2 <= $di2){
							if($end2 > $di2){
								if($mid2 > $di2){
									$dat3['issue'] = $start2;
								}else{
									$dat3['issue'] = $start2."-".$mid2;
								}
							}else{
								$dat3['issue'] = $start2."-".$end2;
							}
							$input = array ("1","2");
							$rand_keys = array_rand ($input, 1);
							$dat3['attr'] = $input[$rand_keys];
							$dat3['status'] = "等待开奖";
							M("jihua_jsk3_attr")->add($dat3);
						}
					}
				}
			}
		}
	}
    //广西快3追号判断  1分钟1次
	public function jihua_gxk3(){
		//广西快3
		$arrgx = $this->get_data("gxk3");
		$resgx = M("jihua_gxk3")->where("is_do = 0")->find();
		$bs = 0;
		$is_z = 0;
		if($resgx){
			if(strpos($resgx['issue'],"-")){
				$nargx = explode("-",$resgx['issue']);
				$newgx = array();
				for($i = $nargx[0];$i<=$nargx[1];$i++){
					$newgx[] = $i;
				}
			}else{
				$newgx[] = trim($resgx['issue']);
			}
			$cogx = count($newgx);
			foreach($newgx as $kgx=>$vgx){
				$stagx = array();
				if($vgx == $arrgx[0]['expect']){
					$hsgx = explode(",",rtrim($resgx['he']));
					if(in_array($arrgx[0]['total'],$hsgx)){
						$is_z = 1;
						$bs = $kgx;
						break;
					}else{
						$is_z = 2;
						$bs = $kgx;
						break;
					}
				}
			}
			//处理
			if($is_z == 1){
				if($bs==0){
					$ccgx = "当前中出";
				}else if($bs==1){
					$ccgx = "2期中出";
				}else{
					$ccgx = "3期中出";
				}
				M("jihua_gxk3")->where("id = '{$resgx['id']}'")->save(array("status"=>$ccgx,"is_do"=>1));
				$startgx = $newgx[$bs]+1;
				$midgx = $newgx[$bs]+2;
				$endgx = $newgx[$bs]+3;
				$digx = date("Ymd")."080";
				if($newgx[$bs]!=$digx){
					if($startgx <= $digx){
						if($endgx > $digx){
							if($midgx > $digx){
								$datgx['issue'] = $startgx;
							}else{
								$datgx['issue'] = $startgx."-".$midgx;
							}
						}else{
							$datgx['issue'] = $startgx."-".$endgx;	
						}
						$numbersgx = range(5, 16);
						//shuffle 将数组顺序随即打乱
						shuffle($numbersgx);
						//array_slice 取该数组中的某一段
						$numgx = 5;
						$resultgx = array_slice($numbersgx, 0, $numgx);
						$datgx['he'] = implode(",", $resultgx);
						$datgx['status'] = "等待开奖";
						M("jihua_gxk3")->add($datgx);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccgx = "等待开奖";
				}else if($bs==1){
					$ccgx = "等待开奖";
				}else{
					$ccgx = "追号失败";
				}
				M("jihua_gxk3")->where("id = '{$resgx['id']}'")->save(array("status"=>$ccgx));
				if($bs==$cogx-1){
					M("jihua_gxk3")->where("id = '{$resgx['id']}'")->save(array("status"=>$ccgx,"is_do"=>1));
					$startgx = $newgx[$bs]+1;
					$midgx = $newgx[$bs]+2;
					$endgx = $newgx[$bs]+3;
					$digx = date("Ymd")."080";
					if($newgx[$bs]!=$digx){
						if($startgx <= $digx){
							if($endgx > $digx){
								if($midgx > $digx){
									$datgx['issue'] = $startgx;
								}else{
									$datgx['issue'] = $startgx."-".$midgx;
								}
							}else{
								$datgx['issue'] = $startgx."-".$endgx;
							}
							$numbersgx = range(5, 16);
							//shuffle 将数组顺序随即打乱
							shuffle($numbersgx);
							//array_slice 取该数组中的某一段
							$numgx = 5;
							$resultgx = array_slice($numbersgx, 0, $numgx);
							$datgx['he'] = implode(",", $resultgx);
							$datgx['status'] = "等待开奖";
							M("jihua_gxk3")->add($datgx);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//--------------------------大小-------------------------------------------
		$resg = M("jihua_gxk3_size")->where("is_do = 0")->find();
		if($resg){
			if(strpos($resg['issue'],"-")){
				$narg = explode("-",$resg['issue']);
				$newg = array();
				for($i = $narg[0];$i<=$narg[1];$i++){
					$newg[] = $i;
				}
			}else{
				$newg[] = trim($resg['issue']);
			}
			$cog = count($newg);
			foreach($newg as $kg=>$vg){
				$stag = array();
				if($vg == $arrgx[0]['expect']){
					if($arrgx[0]['size'] == trim($resg['size'])){
						$is_z = 1;
						$bs = $kg;
						break;
					}else{
						$is_z = 2;
						$bs = $kg;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccg = "当前中出";
				}else if($bs==1){
					$ccg = "2期中出";
				}else{
					$ccg = "3期中出";
				}
				M("jihua_gxk3_size")->where("id = '{$resg['id']}'")->save(array("status"=>$ccg,"is_do"=>1));
				$startg = $newg[$bs]+1;
				$midg = $newg[$bs]+2;
				$endg = $newg[$bs]+3;
				$dig = date("Ymd")."080";
				if($newg[$bs]!=$dig){
					if($startg <= $dig){
						if($endg > $dig){
							if($midg > $dig){
								$datg['issue'] = $startg;
							}else{
								$datg['issue'] = $startg."-".$midg;
							}
						}else{
							$datg['issue'] = $startg."-".$endg;
						}
						$inputg = array ("2","1");
						$rand_keysg = array_rand ($inputg, 1);
						$datg['size'] = $inputg[$rand_keysg];
						$datg['status'] = "等待开奖";
						M("jihua_gxk3_size")->add($datg);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccg = "等待开奖";
				}else if($bs==1){
					$ccg = "等待开奖";
				}else{
					$ccg = "追号失败";
				}
				M("jihua_gxk3_size")->where("id = '{$resg['id']}'")->save(array("status"=>$ccg));
				if($bs==$cog-1){
					M("jihua_gxk3_size")->where("id = '{$resg['id']}'")->save(array("status"=>$ccg,"is_do"=>1));
					$startg = $newg[$bs]+1;
					$midg = $newg[$bs]+2;
					$endg = $newg[$bs]+3;
					$dig = date("Ymd")."080";
					if($newg[$bs]!=$dig){
						if($startg <= $dig){
							if($endg > $dig){
								if($midg > $dig){
									$datg['issue'] = $startg;
								}else{
									$datg['issue'] = $startg."-".$midg;
								}
							}else{
								$datg['issue'] = $startg."-".$endg;
							}
							$inputg = array ("2","1");
							$rand_keysg = array_rand ($inputg, 1);
							$datg['size'] = $inputg[$rand_keysg];
							$datg['status'] = "等待开奖";
							M("jihua_gxk3_size")->add($datg);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//-------------------------单双-------------------------------------------------------
		$resx = M("jihua_gxk3_attr")->where("is_do = 0")->find();
		if($resx){
			if(strpos($resx['issue'],"-")){
				$narx = explode("-",$resx['issue']);
				$newx = array();
				for($i = $narx[0];$i<=$narx[1];$i++){
					$newx[] = $i;
				}
			}else{
				$newx[] = trim($resx['issue']);
			}
			$cox = count($newx);
			foreach($newx as $kx=>$vx){
				$stax= array();
				if($vx == $arrgx[0]['expect']){
					if($arrgx[0]['attr'] == trim($resx['attr'])){
						$is_z = 1;
						$bs = $kx;
						break;
					}else{
						$is_z = 2;
						$bs = $kx;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccx = "当前中出";
				}else if($bs==1){
					$ccx = "2期中出";
				}else{
					$ccx = "3期中出";
				}
				M("jihua_gxk3_attr")->where("id = '{$resx['id']}'")->save(array("status"=>$ccx,"is_do"=>1));
				$startx = $newx[$bs]+1;
				$midx = $newx[$bs]+2;
				$endx = $newx[$bs]+3;
				$dix = date("Ymd")."080";
				if($newx[$bs]!=$dix){
					if($startx <= $dix){
						if($endx > $dix){
							if($midx > $dix){
								$datx['issue'] = $startx;
							}else{
								$datx['issue'] = $startx."-".$midx;
							}
						}else{
							$datx['issue'] = $startx."-".$endx;
						}
						$inputx = array ("1","2");
						$rand_keysx = array_rand ($inputx, 1);
						$datx['attr'] = $inputx[$rand_keysx];
						$datx['status'] = "等待开奖";
						M("jihua_gxk3_attr")->add($datx);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccx = "等待开奖";
				}else if($bs==1){
					$ccx = "等待开奖";
				}else{
					$ccx = "追号失败";
				}
				M("jihua_gxk3_attr")->where("id = '{$resx['id']}'")->save(array("status"=>$ccx));
				if($bs==$cox-1){
					M("jihua_gxk3_attr")->where("id = '{$resx['id']}'")->save(array("status"=>$ccx,"is_do"=>1));
					$startx = $newx[$bs]+1;
					$midx = $newx[$bs]+2;
					$endx = $newx[$bs]+3;
					$dix = date("Ymd")."080";
					if($newx[$bs]!=$dix){
						if($startx <= $dix){
							if($endx > $dix){
								if($midx > $dix){
									$datx['issue'] = $startx;
								}else{
									$datx['issue'] = $startx."-".$midx;
								}
							}else{
								$datx['issue'] = $startx."-".$endx;
							}
							$inputx = array ("1","2");
							$rand_keysx = array_rand ($inputx, 1);
							$datx['attr'] = $inputx[$rand_keysx];
							$datx['status'] = "等待开奖";
							M("jihua_gxk3_attr")->add($datx);
						}
					}
				}
			}
		}
	}
    //湖北快3追号判断  1分钟1次
	public function jihua_hubk3(){
		//湖北快3
		$arrhub = $this->get_data("hubk3");
		$reshub = M("jihua_hubk3")->where("is_do = 0")->find();
		if($reshub){
			$newhub = array();
			if(strpos($reshub['issue'],"-")){
				$narhub = explode("-",$reshub['issue']);
				for($i = $narhub[0];$i<=$narhub[1];$i++){
					$newhub[] = $i;
				}
			}else{
				$newhub[] = trim($reshub['issue']);
			}
			$cohub = count($newhub);
			foreach($newhub as $khub=>$vhub){
				$stahub = array();
				if($vhub == $arrhub[0]['expect']){
					$hshub = explode(",",rtrim($reshub['he']));
					if(in_array($arrhub[0]['total'],$hshub)){
						$is_z = 1;
						$bs = $khub;
						break;
					}else{
						$is_z = 2;
						$bs = $khub;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$cchub = "当前中出";
				}else if($bs==1){
					$cchub = "2期中出";
				}else{
					$cchub = "3期中出";
				}
				M("jihua_hubk3")->where("id = '{$reshub['id']}'")->save(array("status"=>$cchub,"is_do"=>1));
				$starthub = $newhub[$bs]+1;
				$midhub = $newhub[$bs]+2;
				$endhub = $newhub[$bs]+3;
				$dihub = date("Ymd")."078";
				if($newhub[$bs]!=$dihub){
					if($starthub <= $dihub){
						if($endhub > $dihub){
							if($midhub > $dihub){
								$dathub['issue'] = $starthub;
							}else{
								$dathub['issue'] = $starthub."-".$midhub;
							}
						}else{
							$dathub['issue'] = $starthub."-".$endhub;
						}
						$numbershub = range(5, 16);
						//shuffle 将数组顺序随即打乱
						shuffle($numbershub);
						//array_slice 取该数组中的某一段
						$numhub = 5;
						$resulthub = array_slice($numbershub, 0, $numhub);
						$dathub['he'] = implode(",", $resulthub);
						$dathub['status'] = "等待开奖";
						M("jihua_hubk3")->add($dathub);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cchub = "等待开奖";
				}else if($bs==1){
					$cchub = "等待开奖";
				}else{
					$cchub = "追号失败";
				}
				M("jihua_hubk3")->where("id = '{$reshub['id']}'")->save(array("status"=>$cchub));
				if($bs==$cohub-1){
					M("jihua_hubk3")->where("id = '{$reshub['id']}'")->save(array("status"=>$cchub,"is_do"=>1));
					$starthub = $newhub[$bs]+1;
					$midhub = $newhub[$bs]+2;
					$endhub = $newhub[$bs]+3;
					$dihub = date("Ymd")."078";
					if($newhub[$bs]!=$dihub){
						if($starthub <= $dihub){
							if($endhub > $dihub){
								if($midhub > $dihub){
									$dathub['issue'] = $starthub;
								}else{
									$dathub['issue'] = $starthub."-".$midhub;
								}
							}else{
								$dathub['issue'] = $starthub."-".$endhub;
							}
							$numbershub = range(5, 16);
							//shuffle 将数组顺序随即打乱
							shuffle($numbershub);
							//array_slice 取该数组中的某一段
							$numhub = 5;
							$resulthub = array_slice($numbershub, 0, $numhub);
							$dathub['he'] = implode(",", $resulthub);
							$dathub['status'] = "等待开奖";
							M("jihua_hubk3")->add($dathub);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//--------------------------大小-------------------------------------------
		$reshu = M("jihua_hubk3_size")->where("is_do = 0")->find();
		if($reshu){
			if(strpos($reshu['issue'],"-")){
				$narhu = explode("-",$reshu['issue']);
				$newhu = array();
				for($i = $narhu[0];$i<=$narhu[1];$i++){
					$newhu[] = $i;
				}
			}else{
				$newhu[] = trim($reshu['issue']);
			}
			$cohu = count($newhu);
			foreach($newhu as $khu=>$vhu){
				$stahu = array();
				if($vhu == $arrhub[0]['expect']){
					if($arrhub[0]['size'] == trim($reshu['size'])){
						$is_z = 1;
						$bs = $khu;
						break;
					}else{
						$is_z = 2;
						$bs = $khu;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$cchu = "当前中出";
				}else if($bs==1){
					$cchu = "2期中出";
				}else{
					$cchu = "3期中出";
				}
				M("jihua_hubk3_size")->where("id = '{$reshu['id']}'")->save(array("status"=>$cchu,"is_do"=>1));
				$starthu = $newhu[$bs]+1;
				$midhu = $newhu[$bs]+2;
				$endhu = $newhu[$bs]+3;
				$dihu = date("Ymd")."078";
				if($newhu[$bs]!=$dihu){
					if($starthu <= $dihu){
						if($endhu > $dihu){
							if($midhu > $dihu){
								$dathu['issue'] = $starthu;
							}else{
								$dathu['issue'] = $starthu."-".$midhu;
							}
						}else{
							$dathu['issue'] = $starthu."-".$endhu;
						}
						$inputhu = array ("2","1");
						$rand_keyshu = array_rand ($inputhu, 1);
						$dathu['size'] = $inputhu[$rand_keyshu];
						$dathu['status'] = "等待开奖";
						M("jihua_hubk3_size")->add($dathu);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cchu = "等待开奖";
				}else if($bs==1){
					$cchu = "等待开奖";
				}else{
					$cchu = "追号失败";
				}
				M("jihua_hubk3_size")->where("id = '{$reshu['id']}'")->save(array("status"=>$cchu));
				if($bs==$cohu-1){
					M("jihua_hubk3_size")->where("id = '{$reshu['id']}'")->save(array("status"=>$cchu,"is_do"=>1));
					$starthu = $newhu[$bs]+1;
					$midhu = $newhu[$bs]+2;
					$endhu = $newhu[$bs]+3;
					$dihu = date("Ymd")."078";
					if($newhu[$bs]!=$dihu){
						if($starthu <= $dihu){
							if($endhu > $dihu){
								if($midhu > $dihu){
									$dathu['issue'] = $starthu;
								}else{
									$dathu['issue'] = $starthu."-".$midhu;
								}
							}else{
								$dathu['issue'] = $starthu."-".$endhu;
							}
							$inputhu = array ("2","1");
							$rand_keyshu = array_rand ($inputhu, 1);
							$dathu['size'] = $inputhu[$rand_keyshu];
							$dathu['status'] = "等待开奖";
							M("jihua_hubk3_size")->add($dathu);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//-------------------------单双-------------------------------------------------------
		$resb = M("jihua_hubk3_attr")->where("is_do = 0")->find();
		if($resb){
			if(strpos($resb['issue'],"-")){
				$narb = explode("-",$resb['issue']);
				$newb = array();
				for($i = $narb[0];$i<=$narb[1];$i++){
					$newb[] = $i;
				}
			}else{
				$newb[] = trim($resb['issue']);
			}
			$cob = count($newb);
			foreach($newb as $kb=>$vb){
				$stab= array();
				if($vb == $arrhub[0]['expect']){
					if($arrhub[0]['attr'] == trim($resb['attr'])){
						$is_z = 1;
						$bs = $kb;
						break;
					}else{
						$is_z = 2;
						$bs = $k;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccb = "当前中出";
				}else if($bs==1){
					$ccb = "2期中出";
				}else{
					$ccb = "3期中出";
				}
				M("jihua_hubk3_attr")->where("id = '{$resb['id']}'")->save(array("status"=>$ccb,"is_do"=>1));
				$startb = $newb[$bs]+1;
				$midb = $newb[$bs]+2;
				$endb = $newb[$bs]+3;
				$dib = date("Ymd")."078";
				if($newb[$bs]!=$dib){
					if($startb <= $dib){
						if($endb > $dib){
							if($midb > $dib){
								$datb['issue'] = $startb;
							}else{
								$datb['issue'] = $startb."-".$midb;
							}
						}else{
							$datb['issue'] = $startb."-".$endb;
						}
						$inputb = array ("1","2");
						$rand_keysb = array_rand ($inputb, 1);
						$datb['attr'] = $inputb[$rand_keysb];
						$datb['status'] = "等待开奖";
						M("jihua_hubk3_attr")->add($datb);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccb = "等待开奖";
				}else if($bs==1){
					$ccb = "等待开奖";
				}else{
					$ccb = "追号失败";
				}
				M("jihua_hubk3_attr")->where("id = '{$resb['id']}'")->save(array("status"=>$ccb));
				if($bs==$cob-1){
					M("jihua_hubk3_attr")->where("id = '{$resb['id']}'")->save(array("status"=>$ccb,"is_do"=>1));
					$startb = $newb[$bs]+1;
					$midb = $newb[$bs]+2;
					$endb = $newb[$bs]+3;
					$dib = date("Ymd")."078";
					if($newb[$bs]!=$dib){
						if($startb <= $dib){
							if($endb > $dib){
								if($midb > $dib){
									$datb['issue'] = $startb;
								}else{
									$datb['issue'] = $startb."-".$midb;
								}
							}else{
								$datb['issue'] = $startb."-".$endb;
							}
							$inputb = array ("1","2");
							$rand_keysb = array_rand ($inputb, 1);
							$datb['attr'] = $inputb[$rand_keysb];
							$datb['status'] = "等待开奖";
							M("jihua_hubk3_attr")->add($datb);
						}
					}
				}
			}
		}
	}
    //河北快3追号判断  1分钟1次
	public function jihua_hebk3(){
		//河北快3
		$arrheb = $this->get_data("hebk3");
		$resheb = M("jihua_hebk3")->where("is_do = 0")->find();
		$bs = 0;
		$is_z = 0;
		if($resheb){
			$newheb = array();
			if(strpos($resheb['issue'],"-")){
				$narheb = explode("-",$resheb['issue']);
				for($i = $narheb[0];$i<=$narheb[1];$i++){
					$newheb[] = $i;
				}
			}else{
				$newheb[] = trim($resheb['issue']);
			}
			$coheb = count($newheb);
			foreach($newheb as $kheb=>$vheb){
				$staheb = array();
				if($vheb == $arrheb[0]['expect']){
					$hsheb = explode(",",rtrim($resheb['he']));
					if(in_array($arrheb[0]['total'],$hsheb)){
						$is_z = 1;
						$bs = $kheb;
						break;
					}else{
						$is_z = 2;
						$bs = $kheb;
						break;
					}
				}
			}
			//处理
			if($is_z == 1){
				if($bs==0){
					$ccheb = "当前中出";
				}else if($bs==1){
					$ccheb = "2期中出";
				}else{
					$ccheb = "3期中出";
				}
				M("jihua_hebk3")->where("id = '{$resheb['id']}'")->save(array("status"=>$ccheb,"is_do"=>1));
				$startheb = $newheb[$bs]+1;
				$midheb = $newheb[$bs]+2;
				$endheb = $newheb[$bs]+3;
				$diheb = date("Ymd")."081";
				if($newheb[$bs]!=$diheb){
					if($startheb <= $diheb){
						if($endheb > $diheb){
							if($midheb > $diheb){
								$datheb['issue'] = $startheb;
							}else{
								$datheb['issue'] = $startheb."-".$midheb;
							}
						}else{
							$datheb['issue'] = $startheb."-".$endheb;
						}
						$numbersheb = range(5, 16);
						//shuffle 将数组顺序随即打乱
						shuffle($numbersheb);
						//array_slice 取该数组中的某一段
						$numheb = 5;
						$resultheb = array_slice($numbersheb, 0, $numheb);
						$datheb['he'] = implode(",", $resultheb);
						$datheb['status'] = "等待开奖";
						M("jihua_hebk3")->add($datheb);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccheb = "等待开奖";
				}else if($bs==1){
					$ccheb = "等待开奖";
				}else{
					$ccheb = "追号失败";
				}
				M("jihua_hebk3")->where("id = '{$resheb['id']}'")->save(array("status"=>$ccheb));
				if($bs==$coheb-1){
					M("jihua_hebk3")->where("id = '{$resheb['id']}'")->save(array("status"=>$ccheb,"is_do"=>1));
					$startheb = $newheb[$bs]+1;
					$midheb = $newheb[$bs]+2;
					$endheb = $newheb[$bs]+3;
					$diheb = date("Ymd")."081";
					if($newheb[$bs]!=$diheb){
						if($startheb <= $diheb){
							if($endheb > $diheb){
								if($midheb > $diheb){
									$datheb['issue'] = $startheb;
								}else{
									$datheb['issue'] = $startheb."-".$midheb;
								}
							}else{
								$datheb['issue'] = $startheb."-".$endheb;
							}
							$numbersheb = range(5, 16);
							//shuffle 将数组顺序随即打乱
							shuffle($numbersheb);
							//array_slice 取该数组中的某一段
							$numheb = 5;
							$resultheb = array_slice($numbersheb, 0, $numheb);
							$datheb['he'] = implode(",", $resultheb);
							$datheb['status'] = "等待开奖";
							M("jihua_hebk3")->add($datheb);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//--------------------------大小-------------------------------------------
		$reshe = M("jihua_hebk3_size")->where("is_do = 0")->find();
		if($reshe){
			if(strpos($reshe['issue'],"-")){
				$narhe = explode("-",$reshe['issue']);
				$newhe = array();
				for($i = $narhe[0];$i<=$narhe[1];$i++){
					$newhe[] = $i;
				}
			}else{
				$newhe[] = trim($reshe['issue']);
			}
			$cohe = count($newhe);
			foreach($newhe as $khe=>$vhe){
				$stahe = array();
				if($vhe == $arrheb[0]['expect']){
					if($arrheb[0]['size'] == trim($reshe['size'])){
						$is_z = 1;
						$bs = $khe;
						break;
					}else{
						$is_z = 2;
						$bs = $khe;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$cche = "当前中出";
				}else if($bs==1){
					$cche = "2期中出";
				}else{
					$cche = "3期中出";
				}
				M("jihua_hebk3_size")->where("id = '{$reshe['id']}'")->save(array("status"=>$cche,"is_do"=>1));
				$starthe = $newhe[$bs]+1;
				$midhe = $newhe[$bs]+2;
				$endhe = $newhe[$bs]+3;
				$dihe = date("Ymd")."081";
				if($newhe[$bs]!=$dihe){
					if($starthe <= $dihe){
						if($endhe > $dihe){
							if($midhe > $dihe){
								$dathe['issue'] = $starthe;
							}else{
								$dathe['issue'] = $starthe."-".$midhe;
							}
						}else{
							$dathe['issue'] = $starthe."-".$endhe;
						}
						$inputhe = array ("2","1");
						$rand_keyshe = array_rand ($inputhe, 1);
						$dathe['size'] = $inputhe[$rand_keyshe];
						$dathe['status'] = "等待开奖";
						M("jihua_hebk3_size")->add($dathe);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cche = "等待开奖";
				}else if($bs==1){
					$cche = "等待开奖";
				}else{
					$cche = "追号失败";
				}
				M("jihua_hebk3_size")->where("id = '{$reshe['id']}'")->save(array("status"=>$cche));
				if($bs==$cohe-1){
					M("jihua_hebk3_size")->where("id = '{$reshe['id']}'")->save(array("status"=>$cche,"is_do"=>1));
					$starthe = $newhe[$bs]+1;
					$midhe = $newhe[$bs]+2;
					$endhe = $newhe[$bs]+3;
					$dihe = date("Ymd")."081";
					if($newhe[$bs]!=$dihe){
						if($starthe <= $dihe){
							if($endhe > $dihe){
								if($midhe > $dihe){
									$dathe['issue'] = $starthe;
								}else{
									$dathe['issue'] = $starthe."-".$midhe;
								}
							}else{
								$dathe['issue'] = $starthe."-".$endhe;
							}
							$inputhe = array ("2","1");
							$rand_keyshe = array_rand ($inputhe, 1);
							$dathe['size'] = $inputhe[$rand_keyshe];
							$dathe['status'] = "等待开奖";
							M("jihua_hebk3_size")->add($dathe);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//-------------------------单双-------------------------------------------------------
		$resbb = M("jihua_hebk3_attr")->where("is_do = 0")->find();
		if($resbb){
			if(strpos($resbb['issue'],"-")){
				$narbb = explode("-",$resbb['issue']);
				$newbb = array();
				for($i = $narbb[0];$i<=$narbb[1];$i++){
					$newbb[] = $i;
				}
			}else{
				$newbb[] = trim($resbb['issue']);
			}
			$cobb = count($newbb);
			foreach($newbb as $kbb=>$vbb){
				$stabb= array();
				if($vbb == $arrheb[0]['expect']){
					$abbb = substr($vbb,-3);
					if($arrheb[0]['attr'] == trim($resbb['attr'])){
						$is_z = 1;
						$bs = $kbb;
						break;
					}else{
						$is_z = 2;
						$bs = $kbb;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccbb = "当前中出";
				}else if($bs==1){
					$ccbb = "2期中出";
				}else{
					$ccbb = "3期中出";
				}
				M("jihua_hebk3_attr")->where("id = '{$resbb['id']}'")->save(array("status"=>$ccbb,"is_do"=>1));
				$startbb = $newbb[$bs]+1;
				$midbb = $newbb[$bs]+2;
				$endbb = $newbb[$bs]+3;
				$dibb = date("Ymd")."081";
				if($newbb[$bs]!=$dibb){
					if($startbb <= $dibb){
						if($endbb > $dibb){
							if($midbb > $dibb){
								$datbb['issue'] = $startbb;
							}else{
								$datbb['issue'] = $startbb."-".$midbb;
							}
						}else{
							$datbb['issue'] = $startbb."-".$endbb;
						}
						$inputbb = array ("1","2");
						$rand_keysbb = array_rand ($inputbb, 1);
						$datbb['attr'] = $inputbb[$rand_keysbb];
						$datbb['status'] = "等待开奖";
						M("jihua_hebk3_attr")->add($datbb);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccbb = "等待开奖";
				}else if($bs==1){
					$ccbb = "等待开奖";
				}else{
					$ccbb = "追号失败";
				}
				M("jihua_hebk3_attr")->where("id = '{$resbb['id']}'")->save(array("status"=>$ccbb));
				if($bs==$cobb-1){
					M("jihua_hebk3_attr")->where("id = '{$resbb['id']}'")->save(array("status"=>$ccbb,"is_do"=>1));
					$startbb = $newbb[$bs]+1;
					$midbb = $newbb[$bs]+2;
					$endbb = $newbb[$bs]+3;
					$dibb = date("Ymd")."081";
					if($newbb[$bs]!=$dibb){
						if($startbb <= $dibb){
							if($endbb > $dibb){
								if($midbb > $dibb){
									$datbb['issue'] = $startbb;
								}else{
									$datbb['issue'] = $startbb."-".$midbb;
								}
							}else{
								$datbb['issue'] = $startbb."-".$endbb;
							}
							$inputbb = array ("1","2");
							$rand_keysbb = array_rand ($inputbb, 1);
							$datbb['attr'] = $inputbb[$rand_keysbb];
							$datbb['status'] = "等待开奖";
							M("jihua_hebk3_attr")->add($datbb);
						}
					}
				}
			}
		}
	}
    //甘肃快3追号判断  1分钟1次
	public function jihua_gsk3(){
		//甘肃快3
		$arrgs = $this->get_data("gsk3");
		$resgs = M("jihua_gsk3")->where("is_do = 0")->find();
		if($resgs){
			$newgs = array();
			if(strpos($resgs['issue'],"-")){
				$nargs = explode("-",$resgs['issue']);
				for($i = $nargs[0];$i<=$nargs[1];$i++){
					$newgs[] = $i;
				}
			}else{
				$newgs[] = trim($resgs['issue']);
			}
			$cogs = count($newgs);
			foreach($newgs as $kgs=>$vgs){
				$stags = array();
				if($vgs == $arrgs[0]['expect']){
					$hsgs = explode(",",rtrim($resgs['he']));
					if(in_array($arrgs[0]['total'],$hsgs)){
						$is_z = 1;
						$bs = $kgs;
						break;
					}else{
						$is_z = 2;
						$bs = $kgs;
						break;
					}
				}
			}
			//处理
			if($is_z == 1){
				if($bs==0){
					$ccgs = "当前中出";
				}else if($bs==1){
					$ccgs = "2期中出";
				}else{
					$ccgs = "3期中出";
				}
				M("jihua_gsk3")->where("id = '{$resgs['id']}'")->save(array("status"=>$ccgs,"is_do"=>1));
				$startgs = $newgs[$bs]+1;
				$midgs = $newgs[$bs]+2;
				$endgs = $newgs[$bs]+3;
				$digs = date("Ymd")."072";
				if($newgs[$bs]!=$digs){
					if($startgs <= $digs){
						if($endgs > $digs){
							if($midgs > $digs){
								$datgs['issue'] = $startgs;
							}else{
								$datgs['issue'] = $startgs."-".$midgs;
							}
						}else{
							$datgs['issue'] = $startgs."-".$endgs;
						}
						$numbersgs = range(5, 16);
						//shuffle 将数组顺序随即打乱
						shuffle($numbersgs);
						//array_slice 取该数组中的某一段
						$numgs = 5;
						$resultgs = array_slice($numbersgs, 0, $numgs);
						$datgs['he'] = implode(",", $resultgs);
						$datgs['status'] = "等待开奖";
						M("jihua_gsk3")->add($datgs);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccgs = "等待开奖";
				}else if($bs==1){
					$ccgs = "等待开奖";
				}else{
					$ccgs = "追号失败";
				}
				M("jihua_gsk3")->where("id = '{$resgs['id']}'")->save(array("status"=>$ccgs));
				if($bs==$cogs-1){
					M("jihua_gsk3")->where("id = '{$resgs['id']}'")->save(array("status"=>$ccgs,"is_do"=>1));
					$startgs = $newgs[$bs]+1;
					$midgs = $newgs[$bs]+2;
					$endgs = $newgs[$bs]+3;
					$digs = date("Ymd")."072";
					if($newgs[$bs]!=$digs){
						if($startgs <= $digs){
							if($endgs > $digs){
								if($midgs > $digs){
									$datgs['issue'] = $startgs;
								}else{
									$datgs['issue'] = $startgs."-".$midgs;
								}
							}else{
								$datgs['issue'] = $startgs."-".$endgs;
							}
							$numbersgs = range(5, 16);
							//shuffle 将数组顺序随即打乱
							shuffle($numbersgs);
							//array_slice 取该数组中的某一段
							$numgs = 5;
							$resultgs = array_slice($numbersgs, 0, $numgs);
							$datgs['he'] = implode(",", $resultgs);
							$datgs['status'] = "等待开奖";
							M("jihua_gsk3")->add($datgs);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//--------------------------大小-------------------------------------------
		$resg = M("jihua_gsk3_size")->where("is_do = 0")->find();
		if($resg){
			if(strpos($resg['issue'],"-")){
				$narg = explode("-",$resg['issue']);
				$newg = array();
				for($i = $narg[0];$i<=$narg[1];$i++){
					$newg[] = $i;
				}
			}else{
				$newg[] = trim($resg['issue']);
			}
			$cog = count($newg);
			foreach($newg as $kg=>$vg){
				$stag = array();
				if($vg == $arrgs[0]['expect']){
					if($arrgs[0]['size'] == trim($resg['size'])){
						$is_z = 1;
						$bs = $kg;
						break;
					}else{
						$is_z = 2;
						$bs = $kg;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccg = "当前中出";
				}else if($bs==1){
					$ccg = "2期中出";
				}else{
					$ccg = "3期中出";
				}
				M("jihua_gsk3_size")->where("id = '{$resg['id']}'")->save(array("status"=>$ccg,"is_do"=>1));
				$startg = $newg[$bs]+1;
				$midg = $newg[$bs]+2;
				$endg = $newg[$bs]+3;
				$dig = date("Ymd")."072";
				if($newg[$bs]!=$dig){
					if($startg <= $dig){
						if($endg > $dig){
							if($midg > $dig){
								$datg['issue'] = $startg;
							}else{
								$datg['issue'] = $startg."-".$midg;
							}
						}else{
							$datg['issue'] = $startg."-".$endg;
						}
						$inputg = array ("2","1");
						$rand_keysg = array_rand ($inputg, 1);
						$datg['size'] = $inputg[$rand_keysg];
						$datg['status'] = "等待开奖";
						M("jihua_gsk3_size")->add($datg);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccg = "等待开奖";
				}else if($bs==1){
					$ccg = "等待开奖";
				}else{
					$ccg = "追号失败";
				}
				M("jihua_gsk3_size")->where("id = '{$resg['id']}'")->save(array("status"=>$ccg));
				if($bs==$cog-1){
					M("jihua_gsk3_size")->where("id = '{$resg['id']}'")->save(array("status"=>$ccg,"is_do"=>1));
					$startg = $newg[$bs]+1;
					$midg = $newg[$bs]+2;
					$endg = $newg[$bs]+3;
					$dig = date("Ymd")."072";
					if($newg[$bs]!=$dig){
						if($startg <= $dig){
							if($endg > $dig){
								if($midg > $dig){
									$datg['issue'] = $startg;
								}else{
									$datg['issue'] = $startg."-".$midg;
								}
							}else{
								$datg['issue'] = $startg."-".$endg;
							}
							$inputg = array ("2","1");
							$rand_keysg = array_rand ($inputg, 1);
							$datg['size'] = $inputg[$rand_keysg];
							$datg['status'] = "等待开奖";
							M("jihua_gsk3_size")->add($datg);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//-------------------------单双-------------------------------------------------------
		$resss = M("jihua_gsk3_attr")->where("is_do = 0")->find();
		if($resss){
			if(strpos($resss['issue'],"-")){
				$narss = explode("-",$resss['issue']);
				$newss = array();
				for($i = $narss[0];$i<=$narss[1];$i++){
					$newss[] = $i;
				}
			}else{
				$newss[] = trim($resss['issue']);
			}
			$coss = count($newss);
			foreach($newss as $kss=>$vss){
				$stass= array();
				if($vss == $arrgs[0]['expect']){
					$assb = substr($vss,-3);
					if($arrgs[0]['attr'] == trim($resss['attr'])){
						$is_z = 1;
						$bs = $kss;
						break;
					}else{
						$is_z = 2;
						$bs = $kss;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccss = "当前中出";
				}else if($bs==1){
					$ccss = "2期中出";
				}else{
					$ccss = "3期中出";
				}
				M("jihua_gsk3_attr")->where("id = '{$resss['id']}'")->save(array("status"=>$ccss,"is_do"=>1));
				$startss = $newss[$bs]+1;
				$midss = $newss[$bs]+2;
				$endss = $newss[$bs]+3;
				$diss = date("Ymd")."072";
				if($newss[$bs]!=$diss){
					if($startss <= $diss){
						if($endss > $diss){
							if($midss > $diss){
								$datss['issue'] = $startss;
							}else{
								$datss['issue'] = $startss."-".$midss;
							}
						}else{
							$datss['issue'] = $startss."-".$endss;
						}
						$inputss = array ("1","2");
						$rand_keysss = array_rand ($inputss, 1);
						$datss['attr'] = $inputss[$rand_keysss];
						$datss['status'] = "等待开奖";
						M("jihua_gsk3_attr")->add($datss);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccss = "等待开奖";
				}else if($bs==1){
					$ccss = "等待开奖";
				}else{
					$ccss = "追号失败";
				}
				M("jihua_gsk3_attr")->where("id = '{$resss['id']}'")->save(array("status"=>$ccss));
				if($bs==$coss-1){
					M("jihua_gsk3_attr")->where("id = '{$resss['id']}'")->save(array("status"=>$ccss,"is_do"=>1));
					$startss = $newss[$bs]+1;
					$midss = $newss[$bs]+2;
					$endss = $newss[$bs]+3;
					$diss = date("Ymd")."072";
					if($newss[$bs]!=$diss){
						if($startss <= $diss){
							if($endss > $diss){
								if($midss > $diss){
									$datss['issue'] = $startss;
								}else{
									$datss['issue'] = $startss."-".$midss;
								}
							}else{
								$datss['issue'] = $startss."-".$endss;
							}
							$inputss = array ("1","2");
							$rand_keysss = array_rand ($inputss, 1);
							$datss['attr'] = $inputss[$rand_keysss];
							$datss['status'] = "等待开奖";
							M("jihua_gsk3_attr")->add($datss);
						}
					}
				}
			}
		}
	}
    //上海快3追号判断  1分钟1次
	public function jihua_shk3(){
		//上海快3
		$arrsh = $this->get_data("shk3");
		$ressh = M("jihua_shk3")->where("is_do = 0")->find();
		if($ressh){
			$newsh = array();
			if(strpos($ressh['issue'],"-")){
				$narsh = explode("-",$ressh['issue']);
				for($i = $narsh[0];$i<=$narsh[1];$i++){
					$newsh[] = $i;
				}
			}else{
				$newsh[] = trim($ressh['issue']);
			}
			$cosh = count($newsh);
			foreach($newsh as $ksh=>$vsh){
				$stash = array();
				if($vsh == $arrsh[0]['expect']){
					$hssh = explode(",",rtrim($ressh['he']));
					$absh = substr($vsh,-3);
					if(in_array($arrsh[0]['total'],$hssh)){
						$is_z = 1;
						$bs = $ksh;
						break;
					}else{
						$is_z = 2;
						$bs = $ksh;
						break;
					}
				}
			}
			//处理
			if($is_z == 1){
				if($bs==0){
					$ccsh = "当前中出";
				}else if($bs==1){
					$ccsh = "2期中出";
				}else{
					$ccsh = "3期中出";
				}
				M("jihua_shk3")->where("id = '{$ressh['id']}'")->save(array("status"=>$ccsh,"is_do"=>1));
				$startsh = $newsh[$bs]+1;
				$midsh = $newsh[$bs]+2;
				$endsh = $newsh[$bs]+3;
				$dish = date("Ymd")."082";
				if($newsh[$bs]!=$dish){
					if($startsh <= $dish){
						if($endsh > $dish){
							if($midsh > $dish){
								$datsh['issue'] = $startsh;
							}else{
								$datsh['issue'] = $startsh."-".$midsh;
							}
						}else{
							$datsh['issue'] = $startsh."-".$endsh;
						}
						$numberssh = range(5, 16);
						//shuffle 将数组顺序随即打乱
						shuffle($numberssh);
						//array_slice 取该数组中的某一段
						$numsh = 5;
						$resultsh = array_slice($numberssh, 0, $numsh);
						$datsh['he'] = implode(",", $resultsh);
						$datsh['status'] = "等待开奖";
						M("jihua_shk3")->add($datsh);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccsh = "等待开奖";
				}else if($bs==1){
					$ccsh = "等待开奖";
				}else{
					$ccsh = "追号失败";
				}
				M("jihua_shk3")->where("id = '{$ressh['id']}'")->save(array("status"=>$ccsh));
				if($bs==$cosh-1){
					M("jihua_shk3")->where("id = '{$ressh['id']}'")->save(array("status"=>$ccsh,"is_do"=>1));
					$startsh = $newsh[$bs]+1;
					$midsh = $newsh[$bs]+2;
					$endsh = $newsh[$bs]+3;
					$dish = date("Ymd")."082";
					if($newsh[$bs]!=$dish){
						if($startsh <= $dish){
							if($endsh > $dish){
								if($midsh > $dish){
									$datsh['issue'] = $startsh;
								}else{
									$datsh['issue'] = $startsh."-".$midsh;
								}
							}else{
								$datsh['issue'] = $startsh."-".$endsh;
							}
							$numberssh = range(5, 16);
							//shuffle 将数组顺序随即打乱
							shuffle($numberssh);
							//array_slice 取该数组中的某一段
							$numsh = 5;
							$resultsh = array_slice($numberssh, 0, $numsh);
							$datsh['he'] = implode(",", $resultsh);
							$datsh['status'] = "等待开奖";
							M("jihua_shk3")->add($datsh);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//--------------------------大小-------------------------------------------
		$ressh1 = M("jihua_shk3_size")->where("is_do = 0")->find();
		if($ressh1){
			if(strpos($ressh1['issue'],"-")){
				$narsh1 = explode("-",$ressh1['issue']);
				$newsh1 = array();
				for($i = $narsh1[0];$i<=$narsh1[1];$i++){
					$newsh1[] = $i;
				}
			}else{
				$newsh1[] = trim($ressh1['issue']);
			}
			$cosh1 = count($newsh1);
			foreach($newsh1 as $ksh1=>$vsh1){
				$stash1 = array();
				if($vsh1 == $arrsh[0]['expect']){
					$absh1 = substr($vsh1,-3);
					if($arrsh[0]['size'] == trim($ressh1['size'])){
						$is_z = 1;
						$bs = $ksh1;
						break;
					}else{
						$is_z = 2;
						$bs = $ksh1;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccsh1 = "当前中出";
				}else if($bs==1){
					$ccsh1 = "2期中出";
				}else{
					$ccsh1 = "3期中出";
				}
				M("jihua_shk3_size")->where("id = '{$ressh1['id']}'")->save(array("status"=>$ccsh1,"is_do"=>1));
				$startsh1 = $newsh1[$bs]+1;
				$midsh1 = $newsh1[$bs]+2;
				$endsh1 = $newsh1[$bs]+3;
				$dish1 = date("Ymd")."082";
				if($newsh1[$bs]!=$dish1){
					if($startsh1 <= $dish1){
						if($endsh1 > $dish1){
							if($midsh1 > $dish1){
								$datsh1['issue'] = $startsh1;
							}else{
								$datsh1['issue'] = $startsh1."-".$midsh1;
							}
						}else{
							$datsh1['issue'] = $startsh1."-".$endsh1;
						}
						$inputsh1 = array ("2","1");
						$rand_keyssh1 = array_rand ($inputsh1, 1);
						$datsh1['size'] = $inputsh1[$rand_keyssh1];
						$datsh1['status'] = "等待开奖";
						M("jihua_shk3_size")->add($datsh1);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccsh1 = "等待开奖";
				}else if($bs==1){
					$ccsh1 = "等待开奖";
				}else{
					$ccsh1 = "追号失败";
				}
				M("jihua_shk3_size")->where("id = '{$ressh1['id']}'")->save(array("status"=>$ccsh1));
				if($bs==$cosh1-1){
					M("jihua_shk3_size")->where("id = '{$ressh1['id']}'")->save(array("status"=>$ccsh1,"is_do"=>1));
					$startsh1 = $newsh1[$bs]+1;
					$midsh1 = $newsh1[$bs]+2;
					$endsh1 = $newsh1[$bs]+3;
					$dish1 = date("Ymd")."072";
					if($newsh1[$bs]!=$dish1){
						if($startsh1 <= $dish1){
							if($endsh1 > $dish1){
								if($midsh1 > $dish1){
									$datsh1['issue'] = $startsh1;
								}else{
									$datsh1['issue'] = $startsh1."-".$midsh1;
								}
							}else{
								$datsh1['issue'] = $startsh1."-".$endsh1;
							}
							$inputsh1 = array ("2","1");
							$rand_keyssh1 = array_rand ($inputsh1, 1);
							$datsh1['size'] = $inputsh1[$rand_keyssh1];
							$datsh1['status'] = "等待开奖";
							M("jihua_shk3_size")->add($datsh1);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//-------------------------单双-------------------------------------------------------
		$regs = M("jihua_shk3_attr")->where("is_do = 0")->find();
		if($regs){
			if(strpos($regs['issue'],"-")){
				$narg = explode("-",$regs['issue']);
				$newg = array();
				for($i = $narg[0];$i<=$narg[1];$i++){
					$newg[] = $i;
				}
			}else{
				$newg[] = trim($regs['issue']);
			}
			$cog = count($newg);
			foreach($newg as $kg=>$vg){
				$stag= array();
				if($vg == $arrsh[0]['expect']){
					$agb = substr($vg,-3);
					if($arrsh[0]['attr'] == trim($regs['attr'])){
						$is_z = 1;
						$bs = $kg;
						break;
					}else{
						$is_z = 2;
						$bs = $kg;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccg = "当前中出";
				}else if($bs==1){
					$ccg = "2期中出";
				}else{
					$ccg = "3期中出";
				}
				M("jihua_shk3_attr")->where("id = '{$regs['id']}'")->save(array("status"=>$ccg,"is_do"=>1));
				$startg = $newg[$bs]+1;
				$midg = $newg[$bs]+2;
				$endg = $newg[$bs]+3;
				$dig = date("Ymd")."082";
				if($newg[$bs]!=$dig){
					if($startg <= $dig){
						if($endg > $dig){
							if($midg > $dig){
								$datg['issue'] = $startg;
							}else{
								$datg['issue'] = $startg."-".$midg;
							}
						}else{
							$datg['issue'] = $startg."-".$endg;
						}
						$inputg = array ("1","2");
						$rand_keygs = array_rand ($inputg, 1);
						$datg['attr'] = $inputg[$rand_keygs];
						$datg['status'] = "等待开奖";
						M("jihua_shk3_attr")->add($datg);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccg = "等待开奖";
				}else if($bs==1){
					$ccg = "等待开奖";
				}else{
					$ccg = "追号失败";
				}
				M("jihua_shk3_attr")->where("id = '{$regs['id']}'")->save(array("status"=>$ccg));
				if($bs==$cog-1){
					M("jihua_shk3_attr")->where("id = '{$regs['id']}'")->save(array("status"=>$ccg,"is_do"=>1));
					$startg = $newg[$bs]+1;
					$midg = $newg[$bs]+2;
					$endg = $newg[$bs]+3;
					$dig = date("Ymd")."082";
					if($newg[$bs]!=$dig){
						if($startg <= $dig){
							if($endg > $dig){
								if($midg > $dig){
									$datg['issue'] = $startg;
								}else{
									$datg['issue'] = $startg."-".$midg;
								}
							}else{
								$datg['issue'] = $startg."-".$endg;
							}
							$inputg = array ("1","2");
							$rand_keygs = array_rand ($inputg, 1);
							$datg['attr'] = $inputg[$rand_keygs];
							$datg['status'] = "等待开奖";
							M("jihua_shk3_attr")->add($datg);
						}
					}
				}
			}
		}
	}
    //贵州快3追号判断  1分钟1次
	public function jihua_gzk3(){
		//贵州快3
		$arrgz = $this->get_data("gzk3");
		$resgz = M("jihua_gzk3")->where("is_do = 0")->find();
		$bs = 0;
		$is_z = 0;
		if($resgz){
			$newgz = array();
			if(strpos($resgz['issue'],"-")){
				$nargz = explode("-",$resgz['issue']);
				for($i = $nargz[0];$i<=$nargz[1];$i++){
					$newgz[] = $i;
				}
			}else{
				$newgz[] = trim($resgz['issue']);
			}
			$cogz = count($newgz);
			foreach($newgz as $kgz=>$vgz){
				$stagz = array();
				if($vgz == $arrgz[0]['expect']){
					$hsgz = explode(",",rtrim($resgz['he']));
					if(in_array($arrgz[0]['total'],$hsgz)){
						$is_z = 1;
						$bs = $kgz;
						break;
					}else{
						$is_z = 2;
						$bs = $kgz;
						break;
					}
				}
			}
			//处理
			if($is_z == 1){
				if($bs==0){
					$ccgz = "当前中出";
				}else if($bs==1){
					$ccgz = "2期中出";
				}else{
					$ccgz = "3期中出";
				}
				M("jihua_gzk3")->where("id = '{$resgz['id']}'")->save(array("status"=>$ccgz,"is_do"=>1));
				$startgz = $newgz[$bs]+1;
				$midgz = $newgz[$bs]+2;
				$endgz = $newgz[$bs]+3;
				$digz = date("Ymd")."078";
				if($newgz[$bs]!=$digz){
					if($startgz <= $digz){
						if($endgz > $digz){
							if($midgz > $digz){
								$datgz['issue'] = $startgz;
							}else{
								$datgz['issue'] = $startgz."-".$midgz;
							}
						}else{
							$datgz['issue'] = $startgz."-".$endgz;
						}
						$numbersgz = range(5, 16);
						//gzuffle 将数组顺序随即打乱
						shuffle($numbersgz);
						//array_slice 取该数组中的某一段
						$numgz = 5;
						$resultgz = array_slice($numbersgz, 0, $numgz);
						$datgz['he'] = implode(",", $resultgz);
						$datgz['status'] = "等待开奖";
						M("jihua_gzk3")->add($datgz);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccgz = "等待开奖";
				}else if($bs==1){
					$ccgz = "等待开奖";
				}else{
					$ccgz = "追号失败";
				}
				M("jihua_gzk3")->where("id = '{$resgz['id']}'")->save(array("status"=>$ccgz));
				if($bs==$cogz-1){
					M("jihua_gzk3")->where("id = '{$resgz['id']}'")->save(array("status"=>$ccgz,"is_do"=>1));
					$startgz = $newgz[$bs]+1;
					$midgz = $newgz[$bs]+2;
					$endgz = $newgz[$bs]+3;
					$digz = date("Ymd")."078";
					if($newgz[$bs]!=$digz){
						if($startgz <= $digz){
							if($endgz > $digz){
								if($midgz > $digz){
									$datgz['issue'] = $startgz;
								}else{
									$datgz['issue'] = $startgz."-".$midgz;
								}
							}else{
								$datgz['issue'] = $startgz."-".$endgz;
							}
							$numbersgz = range(5, 16);
							//gzuffle 将数组顺序随即打乱
							shuffle($numbersgz);
							//array_slice 取该数组中的某一段
							$numgz = 5;
							$resultgz = array_slice($numbersgz, 0, $numgz);
							$datgz['he'] = implode(",", $resultgz);
							$datgz['status'] = "等待开奖";
							M("jihua_gzk3")->add($datgz);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//--------------------------大小-------------------------------------------
		$resgz1 = M("jihua_gzk3_size")->where("is_do = 0")->find();
		if($resgz1){
			if(strpos($resgz1['issue'],"-")){
				$nargz1 = explode("-",$resgz1['issue']);
				$newgz1 = array();
				for($i = $nargz1[0];$i<=$nargz1[1];$i++){
					$newgz1[] = $i;
				}
			}else{
				$newgz1[] = trim($resgz1['issue']);
			}
			$cogz1 = count($newgz1);
			foreach($newgz1 as $kgz1=>$vgz1){
				$stagz1 = array();
				if($vgz1 == $arrgz[0]['expect']){
					if($arrgz[0]['size'] == trim($resgz1['size'])){
						$is_z = 1;
						$bs = $kgz1;
						break;
					}else{
						$is_z = 2;
						$bs = $kgz1;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccgz1 = "当前中出";
				}else if($bs==1){
					$ccgz1 = "2期中出";
				}else{
					$ccgz1 = "3期中出";
				}
				M("jihua_gzk3_size")->where("id = '{$resgz1['id']}'")->save(array("status"=>$ccgz1,"is_do"=>1));
				$startgz1 = $newgz1[$bs]+1;
				$midgz1 = $newgz1[$bs]+2;
				$endgz1 = $newgz1[$bs]+3;
				$digz1 = date("Ymd")."078";
				if($newgz1[$bs]!=$digz1){
					if($startgz1 <= $digz1){
						if($endgz1 > $digz1){
							if($midgz1 > $digz1){
								$datgz1['issue'] = $startgz1;
							}else{
								$datgz1['issue'] = $startgz1."-".$midgz1;
							}
						}else{
							$datgz1['issue'] = $startgz1."-".$endgz1;
						}
						$inputgz1 = array ("2","1");
						$rand_keysgz1 = array_rand ($inputgz1, 1);
						$datgz1['size'] = $inputgz1[$rand_keysgz1];
						$datgz1['status'] = "等待开奖";
						M("jihua_gzk3_size")->add($datgz1);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccgz1 = "等待开奖";
				}else if($bs==1){
					$ccgz1 = "等待开奖";
				}else{
					$ccgz1 = "追号失败";
				}
				M("jihua_gzk3_size")->where("id = '{$resgz1['id']}'")->save(array("status"=>$ccgz1));
				if($bs==$cogz1-1){
					M("jihua_gzk3_size")->where("id = '{$resgz1['id']}'")->save(array("status"=>$ccgz1,"is_do"=>1));
					$startgz1 = $newgz1[$bs]+1;
					$midgz1 = $newgz1[$bs]+2;
					$endgz1 = $newgz1[$bs]+3;
					$digz1 = date("Ymd")."078";
					if($newgz1[$bs]!=$digz1){
						if($startgz1 <= $digz1){
							if($endgz1 > $digz1){
								if($midgz1 > $digz1){
									$datgz1['issue'] = $startgz1;
								}else{
									$datgz1['issue'] = $startgz1."-".$midgz1;
								}
							}else{
								$datgz1['issue'] = $startgz1."-".$endgz1;
							}
							$inputgz1 = array ("2","1");
							$rand_keysgz1 = array_rand ($inputgz1, 1);
							$datgz1['size'] = $inputgz1[$rand_keysgz1];
							$datgz1['status'] = "等待开奖";
							M("jihua_gzk3_size")->add($datgz1);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//-------------------------单双-------------------------------------------------------
		$regzz = M("jihua_gzk3_attr")->where("is_do = 0")->find();
		if($regzz){
			if(strpos($regzz['issue'],"-")){
				$nargzz = explode("-",$regzz['issue']);
				$newgzz = array();
				for($i = $nargzz[0];$i<=$nargzz[1];$i++){
					$newgzz[] = $i;
				}
			}else{
				$newgzz[] = trim($regzz['issue']);
			}
			$cogzz = count($newgzz);
			foreach($newgzz as $kgzz=>$vgzz){
				$stagzz= array();
				if($vgzz == $arrgz[0]['expect']){
					$agbzz = substr($vgzz,-3);
					if($arrgz[0]['attr'] == trim($regzz['attr'])){
						$is_z = 1;
						$bs = $kgzz;
						break;
					}else{
						$is_z = 2;
						$bs = $kgzz;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccgzz = "当前中出";
				}else if($bs==1){
					$ccgzz = "2期中出";
				}else{
					$ccgzz = "3期中出";
				}
				M("jihua_gzk3_attr")->where("id = '{$regzz['id']}'")->save(array("status"=>$ccgzz,"is_do"=>1));
				$startgzz = $newgzz[$bs]+1;
				$midgzz = $newgzz[$bs]+2;
				$endgzz = $newgzz[$bs]+3;
				$digzz = date("Ymd")."078";
				if($newgzz[$bs]!=$digzz){
					if($startgzz <= $digzz){
						if($endgzz > $digzz){
							if($midgzz > $digzz){
								$datgzz['issue'] = $startgzz;
							}else{
								$datgzz['issue'] = $startgzz."-".$midgzz;
							}
						}else{
							$datgzz['issue'] = $startgzz."-".$endgzz;
						}
						$inputgzz = array ("1","2");
						$rand_keygszz = array_rand ($inputgzz, 1);
						$datgzz['attr'] = $inputgzz[$rand_keygszz];
						$datgzz['status'] = "等待开奖";
						M("jihua_gzk3_attr")->add($datgzz);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccgzz = "等待开奖";
				}else if($bs==1){
					$ccgzz = "等待开奖";
				}else{
					$ccgzz = "追号失败";
				}
				M("jihua_gzk3_attr")->where("id = '{$regzz['id']}'")->save(array("status"=>$ccgzz));
				if($bs==$cogzz-1){
					M("jihua_gzk3_attr")->where("id = '{$regzz['id']}'")->save(array("status"=>$ccgzz,"is_do"=>1));
					$startgzz = $newgzz[$bs]+1;
					$midgzz = $newgzz[$bs]+2;
					$endgzz = $newgzz[$bs]+3;
					$digzz = date("Ymd")."078";
					if($newgzz[$bs]!=$digzz){
						if($startgzz <= $digzz){
							if($endgzz > $digzz){
								if($midgzz > $digzz){
									$datgzz['issue'] = $startgzz;
								}else{
									$datgzz['issue'] = $startgzz."-".$midgzz;
								}
							}else{
								$datgzz['issue'] = $startgzz."-".$endgzz;
							}
							$inputgzz = array ("1","2");
							$rand_keygszz = array_rand ($inputgzz, 1);
							$datgzz['attr'] = $inputgzz[$rand_keygszz];
							$datgzz['status'] = "等待开奖";
							M("jihua_gzk3_attr")->add($datgzz);
						}
					}
				}
			}
		}
	}
    //吉林快3追号判断  1分钟1次
	public function jihua_jlk3(){
		//吉林快3
		$arrjl = $this->get_data("jlk3");
		$resjl = M("jihua_jlk3")->where("is_do = 0")->find();
		$bs = 0;
		$is_z = 0;
		if($resjl){
			$newjl = array();
			if(strpos($resjl['issue'],"-")){
				$narjl = explode("-",$resjl['issue']);
				for($i = $narjl[0];$i<=$narjl[1];$i++){
					$newjl[] = $i;
				}
			}else{
				$newjl[] = trim($resjl['issue']);
			}
			$cojl = count($newjl);
			foreach($newjl as $kjl=>$vjl){
				$stajl = array();
				if($vjl == $arrjl[0]['expect']){
					$hsjl = explode(",",rtrim($resjl['he']));
					if(in_array($arrjl[0]['total'],$hsjl)){
						$is_z = 1;
						$bs = $kjl;
						break;
					}else{
						$is_z = 2;
						$bs = $kjl;
						break;
					}
				}
			}
			//处理
			if($is_z == 1){
				if($bs==0){
					$ccjl = "当前中出";
				}else if($bs==1){
					$ccjl = "2期中出";
				}else{
					$ccjl = "3期中出";
				}
				M("jihua_jlk3")->where("id = '{$resjl['id']}'")->save(array("status"=>$ccjl,"is_do"=>1));
				$startjl = $newjl[$bs]+1;
				$midjl = $newjl[$bs]+2;
				$endjl = $newjl[$bs]+3;
				$dijl = date("Ymd")."079";
				if($newjl[$bs]!=$dijl){
					if($startjl <= $dijl){
						if($endjl > $dijl){
							if($midjl > $dijl){
								$datjl['issue'] = $startjl;
							}else{
								$datjl['issue'] = $startjl."-".$midjl;
							}
						}else{
							$datjl['issue'] = $startjl."-".$endjl;
						}
						$numbersjl = range(5, 16);
						//jluffle 将数组顺序随即打乱
						shuffle($numbersjl);
						//array_slice 取该数组中的某一段
						$numjl = 5;
						$resultjl = array_slice($numbersjl, 0, $numjl);
						$datjl['he'] = implode(",", $resultjl);
						$datjl['status'] = "等待开奖";
						M("jihua_jlk3")->add($datjl);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccjl = "等待开奖";
				}else if($bs==1){
					$ccjl = "等待开奖";
				}else{
					$ccjl = "追号失败";
				}
				M("jihua_jlk3")->where("id = '{$resjl['id']}'")->save(array("status"=>$ccjl));
				if($bs==$cojl-1){
					M("jihua_jlk3")->where("id = '{$resjl['id']}'")->save(array("status"=>$ccjl,"is_do"=>1));
					$startjl = $newjl[$bs]+1;
					$midjl = $newjl[$bs]+2;
					$endjl = $newjl[$bs]+3;
					$dijl = date("Ymd")."079";
					if($newjl[$bs]!=$dijl){
						if($startjl <= $dijl){
							if($endjl > $dijl){
								if($midjl > $dijl){
									$datjl['issue'] = $startjl;
								}else{
									$datjl['issue'] = $startjl."-".$midjl;
								}
							}else{
								$datjl['issue'] = $startjl."-".$endjl;
							}
							$numbersjl = range(5, 16);
							//jluffle 将数组顺序随即打乱
							shuffle($numbersgz);
							//array_slice 取该数组中的某一段
							$numjl = 5;
							$resultjl = array_slice($numbersjl, 0, $numjl);
							$datjl['he'] = implode(",", $resultjl);
							$datjl['status'] = "等待开奖";
							M("jihua_jlk3")->add($datjl);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//--------------------------大小-------------------------------------------
		$resjl1 = M("jihua_jlk3_size")->where("is_do = 0")->find();
		if($resjl1){
			if(strpos($resjl1['issue'],"-")){
				$narjl1 = explode("-",$resjl1['issue']);
				$newjl1 = array();
				for($i = $narjl1[0];$i<=$narjl1[1];$i++){
					$newjl1[] = $i;
				}
			}else{
				$newjl1[] = trim($resjl1['issue']);
			}
			$cojl1 = count($newjl1);
			foreach($newjl1 as $kjl1=>$vjl1){
				$stajl1 = array();
				if($vjl1 == $arrjl[0]['expect']){
					if($arrjl[0]['size'] == trim($resjl1['size'])){
						$is_z = 1;
						$bs = $kjl1;
						break;
						
					}else{
						$is_z = 2;
						$bs = $kjl1;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccjl1 = "当前中出";
				}else if($bs==1){
					$ccjl1 = "2期中出";
				}else{
					$ccjl1 = "3期中出";
				}
				M("jihua_jlk3_size")->where("id = '{$resjl1['id']}'")->save(array("status"=>$ccjl1,"is_do"=>1));
				$startjl1 = $newjl1[$bs]+1;
				$midjl1 = $newjl1[$bs]+2;
				$endjl1 = $newjl1[$bs]+3;
				$dijl1 = date("Ymd")."079";
				if($newjl1[$bs]!=$dijl1){
					if($startjl1 <= $dijl1){
						if($endjl1 > $dijl1){
							if($midjl1 > $dijl1){
								$datjl1['issue'] = $startjl1;
							}else{
								$datjl1['issue'] = $startjl1."-".$midjl1;
							}
						}else{
							$datjl1['issue'] = $startjl1."-".$endjl1;
						}
						$inputjl1 = array ("2","1");
						$rand_keysjl1 = array_rand ($inputjl1, 1);
						$datjl1['size'] = $inputjl1[$rand_keysjl1];
						$datjl1['status'] = "等待开奖";
						M("jihua_jlk3_size")->add($datjl1);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccjl1 = "等待开奖";
				}else if($bs==1){
					$ccjl1 = "等待开奖";
				}else{
					$ccjl1 = "追号失败";
				}
				M("jihua_jlk3_size")->where("id = '{$resjl1['id']}'")->save(array("status"=>$ccjl1));
				if($bs==$cojl1-1){
					M("jihua_jlk3_size")->where("id = '{$resjl1['id']}'")->save(array("status"=>$ccjl1,"is_do"=>1));
					$startjl1 = $newjl1[$bs]+1;
					$midjl1 = $newjl1[$bs]+2;
					$endjl1 = $newjl1[$bs]+3;
					$dijl1 = date("Ymd")."079";
					if($newjl1[$bs]!=$dijl1){
						if($startjl1 <= $dijl1){
							if($endjl1 > $dijl1){
								if($midjl1 > $dijl1){
									$datjl1['issue'] = $startjl1;
								}else{
									$datjl1['issue'] = $startjl1."-".$midjl1;
								}
							}else{
								$datjl1['issue'] = $startjl1."-".$endjl1;
							}
							$inputjl1 = array ("2","1");
							$rand_keysjl1 = array_rand ($inputjl1, 1);
							$datjl1['size'] = $inputjl1[$rand_keysjl1];
							$datjl1['status'] = "等待开奖";
							M("jihua_jlk3_size")->add($datjl1);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//-------------------------单双-------------------------------------------------------
		$regj = M("jihua_jlk3_attr")->where("is_do = 0")->find();
		if($regj){
			if(strpos($regj['issue'],"-")){
				$nargj = explode("-",$regj['issue']);
				$newgj = array();
				for($i = $nargj[0];$i<=$nargj[1];$i++){
					$newgj[] = $i;
				}
			}else{
				$newgj[] = trim($regj['issue']);
			}
			$cogj = count($newgj);
			foreach($newgj as $kgj=>$vgj){
				$stagj= array();
				if($vgj == $arrjl[0]['expect']){
					if($arrjl[0]['attr'] == trim($regj['attr'])){
						$is_z = 1;
						$bs = $kgj;
						break;
					}else{
						$is_z = 2;
						$bs = $kgj;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccgj = "当前中出";
				}else if($bs==1){
					$ccgj = "2期中出";
				}else{
					$ccgj = "3期中出";
				}
				M("jihua_jlk3_attr")->where("id = '{$regj['id']}'")->save(array("status"=>$ccgj,"is_do"=>1));
				$startgj = $newgj[$bs]+1;
				$midgj = $newgj[$bs]+2;
				$endgj = $newgj[$bs]+3;
				$digj = date("Ymd")."079";
				if($newgj[$bs]!=$digj){
					if($startgj <= $digj){
						if($endgj > $digj){
							if($midgj > $digj){
								$datgj['issue'] = $startgj;
							}else{
								$datgj['issue'] = $startgj."-".$midgj;
							}
						}else{
							$datgj['issue'] = $startgj."-".$endgj;
						}
						$inputgj = array ("1","2");
						$rand_keygsj = array_rand ($inputgj, 1);
						$datgj['attr'] = $inputgj[$rand_keygsj];
						$datgj['status'] = "等待开奖";
						M("jihua_jlk3_attr")->add($datgj);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccgj = "等待开奖";
				}else if($bs==1){
					$ccgj = "等待开奖";
				}else{
					$ccgj = "追号失败";
				}
				M("jihua_jlk3_attr")->where("id = '{$regj['id']}'")->save(array("status"=>$ccgj));
				if($bs==$cogj-1){
					M("jihua_jlk3_attr")->where("id = '{$regj['id']}'")->save(array("status"=>$ccgj,"is_do"=>1));
					$startgj = $newgj[$bs]+1;
					$midgj = $newgj[$bs]+2;
					$endgj = $newgj[$bs]+3;
					$digj = date("Ymd")."079";
					if($newgj[$bs]!=$digj){
						if($startgj <= $digj){
							if($endgj > $digj){
								if($midgj > $digj){
									$datgj['issue'] = $startgj;
								}else{
									$datgj['issue'] = $startgj."-".$midgj;
								}
							}else{
								$datgj['issue'] = $startgj."-".$endgj;
							}
							$inputgj = array ("1","2");
							$rand_keygsj = array_rand ($inputgj, 1);
							$datgj['attr'] = $inputgj[$rand_keygsj];
							$datgj['status'] = "等待开奖";
							M("jihua_jlk3_attr")->add($datgj);
						}
					}
				}
			}
		}
	}
    //北京快3追号判断  1分钟1次
	public function jihua_bjk3(){
		//北京快3
		$ttt = date("Y-m-d");
		$st = M("day_start")->where("date = '{$ttt}' and type = 1")->find();
		$arrbj = $this->get_data("bjk3");
		$resbj = M("jihua_bjk3")->where("is_do = 0")->find();
		$bs = 0;
		$is_z = 0;
		if($resbj){
			$newbj = array();
			if(strpos($resbj['issue'],"-")){
				$narbj = explode("-",$resbj['issue']);
				for($i = $narbj[0];$i<=$narbj[1];$i++){
					if($i!=$narbj[0]){
						$newbj[] = '0'.$i;
					}else{
						$newbj[] = $i;
					}
				}
			}else{
				$newbj[] = trim($resbj['issue']);
			}
			$cobj = count($newbj);
			foreach($newbj as $kbj=>$vbj){
				$stabj = array();
				if($vbj == $arrbj[0]['expect']){
					$hsbj = explode(",",rtrim($resbj['he']));
					if(in_array($arrbj[0]['total'],$hsbj)){
						$is_z = 1;
						$bs = $kbj;
						break;
					}else{
						$is_z = 2;
						$bs = $kbj;
						break;
					}
				}
			}
			//处理
			if($is_z == 1){
				if($bs==0){
					$ccbj = "当前中出";
				}else if($bs==1){
					$ccbj = "2期中出";
				}else{
					$ccbj = "3期中出";
				}
				M("jihua_bjk3")->where("id = '{$resbj['id']}'")->save(array("status"=>$ccbj,"is_do"=>1));
				$startbj = '0'.($newbj[$bs]+1);
				$midbj = '0'.($newbj[$bs]+2);
				$endbj = '0'.($newbj[$bs]+3);
				$dibj = '0'.($st['issue'] + 89);
				if($newbj[$bs]!=$dibj){
					if($startbj <= $dibj){
						if($endbj > $dibj){
							if($midbj > $dibj){
								$datbj['issue'] = $startbj;
							}else{
								$datbj['issue'] = $startbj."-".$midbj;
							}
						}else{
							$datbj['issue'] = $startbj."-".$endbj;
						}
						$numbersbj = range(5, 16);
						//bjuffle 将数组顺序随即打乱
						shuffle($numbersbj);
						//array_slice 取该数组中的某一段
						$numbj = 5;
						$resultbj = array_slice($numbersbj, 0, $numbj);
						$datbj['he'] = implode(",", $resultbj);
						$datbj['status'] = "等待开奖";
						M("jihua_bjk3")->add($datbj);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccbj = "等待开奖";
				}else if($bs==1){
					$ccbj = "等待开奖";
				}else{
					$ccbj = "追号失败";
				}
				M("jihua_bjk3")->where("id = '{$resbj['id']}'")->save(array("status"=>$ccbj));
				if($bs==$cobj-1){
					M("jihua_bjk3")->where("id = '{$resbj['id']}'")->save(array("status"=>$ccbj,"is_do"=>1));
					$startbj = '0'.($newbj[$bs]+1);
					$midbj = '0'.($newbj[$bs]+2);
					$endbj = '0'.($newbj[$bs]+3);
					$dibj = '0'.($st['issue'] + 89);
					if($newbj[$bs]!=$dibj){
						if($startbj <= $dibj){
							if($endbj > $dibj){
								if($midbj > $dibj){
									$datbj['issue'] = $startbj;
								}else{
									$datbj['issue'] = $startbj."-".$midbj;
								}
							}else{
								$datbj['issue'] = $startbj."-".$endbj;
							}
							$numbersbj = range(5, 16);
							//bjuffle 将数组顺序随即打乱
							shuffle($numbersgz);
							//array_slice 取该数组中的某一段
							$numbj = 5;
							$resultbj = array_slice($numbersbj, 0, $numbj);
							$datbj['he'] = implode(",", $resultbj);
							$datbj['status'] = "等待开奖";
							M("jihua_bjk3")->add($datbj);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//--------------------------大小-------------------------------------------
		$resbj1 = M("jihua_bjk3_size")->where("is_do = 0")->find();
		if($resbj1){
			$newbj1 = array();
			if(strpos($resbj1['issue'],"-")){
				$narbj1 = explode("-",$resbj1['issue']);
				for($i = $narbj1[0];$i<=$narbj1[1];$i++){
					if($i!=$narbj1[0]){
						$newbj1[] = '0'.$i;
					}else{
						$newbj1[] = $i;
					}
				}
			}else{
				$newbj1[] = trim($resbj1['issue']);
			}
			$cobj1 = count($newbj1);
			foreach($newbj1 as $kbj1=>$vbj1){
				$stabj1 = array();
				if($vbj1 == $arrbj[0]['expect']){
					if($arrbj[0]['size'] == trim($resbj1['size'])){
						$is_z = 1;
						$bs = $kbj1;
						break;
					}else{
						$is_z = 2;
						$bs = $kbj1;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccbj1 = "当前中出";
				}else if($bs==1){
					$ccbj1 = "2期中出";
				}else{
					$ccbj1 = "3期中出";
				}
				M("jihua_bjk3_size")->where("id = '{$resbj1['id']}'")->save(array("status"=>$ccbj1,"is_do"=>1));
				$startbj1 = '0'.($newbj1[$bs]+1);
				$midbj1 = '0'.($newbj1[$bs]+2);
				$endbj1 = '0'.($newbj1[$bs]+3);
				$dibj1 = '0'.($st['issue'] + 89);
				if($newbj1[$bs]!=$dibj1){
					if($startbj1 <= $dibj1){
						if($endbj1 > $dibj1){
							if($midbj1 > $dibj1){
								$datbj1['issue'] = $startbj1;
							}else{
								$datbj1['issue'] = $startbj1."-".$midbj1;
							}
						}else{
							$datbj1['issue'] = $startbj1."-".$endbj1;
						}
						$inputbj1 = array ("2","1");
						$rand_keysbj1 = array_rand ($inputbj1, 1);
						$datbj1['size'] = $inputbj1[$rand_keysbj1];
						$datbj1['status'] = "等待开奖";
						M("jihua_bjk3_size")->add($datbj1);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccbj1 = "等待开奖";
				}else if($bs==1){
					$ccbj1 = "等待开奖";
				}else{
					$ccbj1 = "追号失败";
				}
				M("jihua_bjk3_size")->where("id = '{$resbj1['id']}'")->save(array("status"=>$ccbj1));
				if($bs==$cobj1-1){
					M("jihua_bjk3_size")->where("id = '{$resbj1['id']}'")->save(array("status"=>$ccbj1,"is_do"=>1));
					$startbj1 = '0'.($newbj1[$bs]+1);
					$midbj1 = '0'.($newbj1[$bs]+2);
					$endbj1 = '0'.($newbj1[$bs]+3);
					$dibj1 = '0'.($st['issue'] + 89);
					if($newbj1[$bs]!=$dibj1){
						if($startbj1 <= $dibj1){
							if($endbj1 > $dibj1){
								if($midbj1 > $dibj1){
									$datbj1['issue'] = $startbj1;
								}else{
									$datbj1['issue'] = $startbj1."-".$midbj1;
								}
							}else{
								$datbj1['issue'] = $startbj1."-".$endbj1;
							}
							$inputbj1 = array ("2","1");
							$rand_keysbj1 = array_rand ($inputbj1, 1);
							$datbj1['size'] = $inputbj1[$rand_keysbj1];
							$datbj1['status'] = "等待开奖";
							M("jihua_bjk3_size")->add($datbj1);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//-------------------------单双-------------------------------------------------------
		$rebgj = M("jihua_bjk3_attr")->where("is_do = 0")->find();
		if($rebgj){
			if(strpos($rebgj['issue'],"-")){
				$nargj = explode("-",$rebgj['issue']);
				$newgj = array();
				for($i = $nargj[0];$i<=$nargj[1];$i++){
					if($i!=$nargj[0]){
						$newgj[] = '0'.$i;
					}else{
						$newgj[] = $i;
					}
				}
			}else{
				$newgj[] = trim($rebgj['issue']);
			}
			$cogj = count($newgj);
			foreach($newgj as $kgj=>$vgj){
				$stagj= array();
				if($vgj == $arrbj[0]['expect']){
					if($arrbj[0]['attr'] == trim($rebgj['attr'])){
						$is_z = 1;
						$bs = $kgj;
						break;
					}else{
						$is_z = 2;
						$bs = $kgj;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccgj = "当前中出";
				}else if($bs==1){
					$ccgj = "2期中出";
				}else{
					$ccgj = "3期中出";
				}
				M("jihua_bjk3_attr")->where("id = '{$rebgj['id']}'")->save(array("status"=>$ccgj,"is_do"=>1));
				$startgj = '0'.($newgj[$bs]+1);
				$midgj = '0'.($newgj[$bs]+2);
				$endgj = '0'.($newgj[$bs]+3);
				$digj = '0'.($st['issue'] + 89);
				if($newgj[$bs]!=$digj){
					if($startgj <= $digj){
						if($endgj > $digj){
							if($midgj > $digj){
								$datgj['issue'] = $startgj;
							}else{
								$datgj['issue'] = $startgj."-".$midgj;
							}
						}else{
							$datgj['issue'] = $startgj."-".$endgj;
						}
						$inputgj = array ("1","2");
						$rand_keygsj = array_rand ($inputgj, 1);
						$datgj['attr'] = $inputgj[$rand_keygsj];
						$datgj['status'] = "等待开奖";
						M("jihua_bjk3_attr")->add($datgj);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccgj = "等待开奖";
				}else if($bs==1){
					$ccgj = "等待开奖";
				}else{
					$ccgj = "追号失败";
				}
				M("jihua_bjk3_attr")->where("id = '{$rebgj['id']}'")->save(array("status"=>$ccgj));
				if($bs==$cogj-1){
					M("jihua_bjk3_attr")->where("id = '{$rebgj['id']}'")->save(array("status"=>$ccgj,"is_do"=>1));
					$startgj = '0'.($newgj[$bs]+1);
					$midgj = '0'.($newgj[$bs]+2);
					$endgj = '0'.($newgj[$bs]+3);
					$digj = '0'.($st['issue'] + 89);
					if($newgj[$bs]!=$digj){
						if($startgj <= $digj){
							if($endgj > $digj){
								if($midgj > $digj){
									$datgj['issue'] = $startgj;
								}else{
									$datgj['issue'] = $startgj."-".$midgj;
								}
							}else{
								$datgj['issue'] = $startgj."-".$endgj;
							}
							$inputgj = array ("1","2");
							$rand_keygsj = array_rand ($inputgj, 1);
							$datgj['attr'] = $inputgj[$rand_keygsj];
							$datgj['status'] = "等待开奖";
							M("jihua_bjk3_attr")->add($datgj);
						}
					}
				}
			}
		}
	}
    //pk10追号判断  1分钟1次
	public function is_zhui(){
		//pk10
		$ttt = date("Y-m-d");
		$st = M("day_start")->where("date = '{$ttt}' and type = 3")->find();
		$arrpk = $this->get_data("bjpk10");
		$respk = M("jihua_pk10")->where("is_do = 0")->find();
		
		$tr1= explode("-",$st1['issue']);
		$bs = 0;
		$is_z = 0;
		if($respk){
			$newpk = array();
			if(strpos($respk['issue'],"-")){
				$narpk = explode("-",$respk['issue']);
				for($i = $narpk[0];$i<=$narpk[1];$i++){
					$newpk[] = $i;
				}
			}else{
				$newpk[] = trim($respk['issue']);
			}
			$copk = count($newpk);
			foreach($newpk as $kpk=>$vpk){
				$stapk = array();
				if($vpk == $arrpk[0]['expect']){
					$hspk = explode(",",rtrim($respk['he']));
					if(in_array($arrpk[0]['ocode']['0'],$hspk)){
						$is_z = 1;
						$bs = $kpk;
						break;
					}else{
						$is_z = 2;
						$bs = $kpk;
						break;
					}
				}
			}
			//处理
			if($is_z == 1){
				if($bs==0){
					$ccpk = "当前中出";
				}else if($bs==1){
					$ccpk = "2期中出";
				}else{
					$ccpk = "3期中出";
				}
				M("jihua_pk10")->where("id = '{$respk['id']}'")->save(array("status"=>$ccpk,"is_do"=>1));
				$startpk = $newpk[$bs]+1;
				$midpk = $newpk[$bs]+2;
				$endpk = $newpk[$bs]+3;
				$dipk = $st['issue'] + 179;
				if($newpk[$bs]!=$dipk){
					if($startpk <= $dipk){
						if($endpk > $dipk){
							if($midpk > $dipk){
								$datpk['issue'] = $startpk;
							}else{
								$datpk['issue'] = $startpk."-".$midpk;
							}
						}else{
							$datpk['issue'] = $startpk."-".$endpk;
						}
						$ci = array();
						$arrg=range(1,10);
						shuffle($arrg);
						foreach($arrg as $key=>$values)
						{
							if($key<5){
								if(strlen($values)=='1'){
									$ci[] = '0'.$values;
								}else{
									$ci[] = $values;
								}
							}
						}
						$datpk['he'] = implode(",", $ci);
						$datpk['status'] = "等待开奖";
						M("jihua_pk10")->add($datpk);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$ccpk = "等待开奖";
				}else if($bs==1){
					$ccpk = "等待开奖";
				}else{
					$ccpk = "追号失败";
				}
				M("jihua_pk10")->where("id = '{$respk['id']}'")->save(array("status"=>$ccpk));
				if($bs==$copk-1){
					M("jihua_pk10")->where("id = '{$respk['id']}'")->save(array("status"=>$ccpk,"is_do"=>1));
					$startpk = $newpk[$bs]+1;
					$midpk = $newpk[$bs]+2;
					$endpk = $newpk[$bs]+3;
					$dipk = $st['issue'] + 179;
					if($newpk[$bs]!=$dipk){
						if($startpk <= $dipk){
							if($endpk > $dipk){
								if($midpk > $dipk){
									$datpk['issue'] = $startpk;
								}else{
									$datpk['issue'] = $startpk."-".$midpk;
								}
							}else{
								$datpk['issue'] = $startpk."-".$endpk;
							}
							$ci = array();
							$arrg=range(1,10);
							shuffle($arrg);
							foreach($arrg as $key=>$values)
							{
								if($key<5){
									if(strlen($values)=='1'){
										$ci[] = '0'.$values;
									}else{
										$ci[] = $values;
									}
								}
							}
							$datpk['he'] = implode(",", $ci);
							$datpk['status'] = "等待开奖";
							M("jihua_pk10")->add($datpk);
						}
					}
				}
			}
		}
	}
    //重庆时时彩追号判断  1分钟1次
	public function is_cqssc(){
		//重庆时时彩
		$arrcq = $this->get_data("cqssc");
		$rescq = M("jihua_ssc_gw")->where("is_do = 0")->find();
		$bs = 0;
		$is_z = 0;
		if($rescq){
			if(strpos($rescq['issue'],"-")){
				$narcq = explode("-",$rescq['issue']);
				$newcq = array();
				for($i = $narcq[0];$i<=$narcq[1];$i++){
					$newcq[] = $i;
				}
			}else{
				$newcq[] = trim($rescq['issue']);
			}
			$cocq = count($newcq);
			foreach($newcq as $kcq=>$vcq){
				$stacq = array();
				if($vcq == $arrcq[0]['expect']){
					$hscq = explode(",",rtrim($rescq['he']));
					$abcq = substr($vcq,-3);
					if(in_array($arrcq[0]['ocode']['4'],$hscq)){
						$is_z = 1;
						$bs = $kcq;
						break;
					}else{
						$is_z = 2;
						$bs = $kcq;
						break;
					}
				}
			}
			//处理
			if($is_z == 1){
				if($bs==0){
					$cccq = "当前中出";
				}else if($bs==1){
					$cccq = "2期中出";
				}else{
					$cccq = "3期中出";
				}
				M("jihua_ssc_gw")->where("id = '{$rescq['id']}'")->save(array("status"=>$cccq,"is_do"=>1));
				$startcq = $newcq[$bs]+1;
				$midcq = $newcq[$bs]+2;
				$endcq = $newcq[$bs]+3;
				$dicq = "120";
				if(substr($newcq[$bs],-3)!=$dicq){
					if(substr($startcq,-3) <= $dicq){
						if(substr($endcq,-3) > $dicq){
							if(substr($midcq,-3) > $dicq){
								$dat1cq['issue'] = $startcq;
							}else{
								$dat1cq['issue'] = $startcq."-".$midcq;
								$nyicq = explode("-",$dat1cq['issue']);
							}
						}else{
							$dat1cq['issue'] = $startcq."-".$endcq;
							$nyicq = explode("-",$dat1cq['issue']);
						}
						$numberscq = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numberscq);
						//array_slice 取该数组中的某一段
						$numcq = 5;
						$resultcq = array_slice($numberscq, 0, $numcq);
						$dat1cq['he'] = implode(",", $resultcq);
						$dat1cq['status'] = "等待开奖";
						M("jihua_ssc_gw")->add($dat1cq);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_ssc_gw")->where("id = '{$rescq['id']}'")->save(array("status"=>$cc4));
				if($bs==$cocq-1){
					M("jihua_ssc_gw")->where("id = '{$rescq['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newcq[$bs]+1;
					$mid4 = $newcq[$bs]+2;
					$end4 = $newcq[$bs]+3;
					$di4 = "120";
					if(substr($newcq[$bs],-3)!=$di4){
						if(substr($start4,-3) <= $di4){
							if(substr($end4,-3) > $di4){
								if(substr($mid4,-3) > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_ssc_gw")->add($dat14);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//十位
		$ressw = M("jihua_ssc_sw")->where("is_do = 0")->find();
		if($ressw){
			if(strpos($rescq['issue'],"-")){
				$narsw = explode("-",$ressw['issue']);
				$newsw = array();
				for($i = $narsw[0];$i<=$narsw[1];$i++){
					$newsw[] = $i;
				}
			}else{
				$newsw[] = trim($ressw['issue']);
			}
			$cosw = count($newsw);
			foreach($newsw as $ksw=>$vsw){
				$stasw = array();
				if($vsw == $arrcq[0]['expect']){
					$hssw = explode(",",rtrim($ressw['he']));
					if(in_array($arrcq[0]['ocode']['3'],$hssw)){
						$is_z = 1;
						$bs = $ksw;
						break;
					}else{
						$is_z = 2;
						$bs = $ksw;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccsw = "当前中出";
				}else if($bs==1){
					$ccsw = "2期中出";
				}else{
					$ccsw = "3期中出";
				}
				M("jihua_ssc_sw")->where("id = '{$ressw['id']}'")->save(array("status"=>$ccsw,"is_do"=>1));
				$startsw = $newsw[$bs]+1;
				$midsw = $newsw[$bs]+2;
				$endsw = $newsw[$bs]+3;
				$disw = "120";
				if(substr($newsw[$bs],-3)!=$disw){
					if(substr($startsw,-3) <= $disw){
						if(substr($endsw,-3) > $disw){
							if(substr($midsw,-3) > $disw){
								$dat1sw['issue'] = $startsw;
							}else{
								$dat1sw['issue'] = $startsw."-".$midsw;
								$nyisw = explode("-",$dat1sw['issue']);
							}
						}else{
							$dat1sw['issue'] = $startsw."-".$endsw;
							$nyisw = explode("-",$dat1sw['issue']);
						}
						$numberssw = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numberssw);
						//array_slice 取该数组中的某一段
						$numsw = 5;
						$resultsw = array_slice($numberssw, 0, $numsw);
						$dat1sw['he'] = implode(",", $resultsw);
						$dat1sw['status'] = "等待开奖";
						M("jihua_ssc_sw")->add($dat1sw);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_ssc_sw")->where("id = '{$ressw['id']}'")->save(array("status"=>$cc4));
				if($bs==$cosw-1){
					M("jihua_ssc_sw")->where("id = '{$ressw['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newsw[$bs]+1;
					$mid4 = $newsw[$bs]+2;
					$end4 = $newsw[$bs]+3;
					$di4 = "120";
					if(substr($newsw[$bs],-3)==$di4){
						if(substr($start4,-3) <= $di4){
							if(substr($end4,-3) > $di4){
								if(substr($mid4,-3) > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_ssc_sw")->add($dat14);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//百位
		$resbw = M("jihua_ssc_bw")->where("is_do = 0")->find();
		if($resbw){
			if(strpos($rescq['issue'],"-")){
				$narbw = explode("-",$resbw['issue']);
				$newbw = array();
				for($i = $narbw[0];$i<=$narbw[1];$i++){
					$newbw[] = $i;
				}
			}else{
				$newbw[] = trim($resbw['issue']);
			}
			$cobw = count($newbw);
			foreach($newbw as $kbw=>$vbw){
				$stabw = array();
				if($vbw == $arrcq[0]['expect']){
					$hsbw = explode(",",rtrim($resbw['he']));
					if(in_array($arrcq[0]['ocode']['2'],$hsbw)){
						$is_z = 1;
						$bs = $kbw;
						break;
					}else{
						$is_z = 2;
						$bs = $kbw;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccbw = "当前中出";
				}else if($bs==1){
					$ccbw = "2期中出";
				}else{
					$ccbw = "3期中出";
				}
				M("jihua_ssc_bw")->where("id = '{$resbw['id']}'")->save(array("status"=>$ccbw,"is_do"=>1));
				$startbw = $newbw[$bs]+1;
				$midbw = $newbw[$bs]+2;
				$endbw = $newbw[$bs]+3;
				$dibw = "120";
				if(substr($newbw[$bs],-3)!=$dibw){
					if(substr($startbw,-3) <= $dibw){
						if(substr($endbw,-3) > $dibw){
							if(substr($midbw,-3) > $dibw){
								$dat1bw['issue'] = $startbw;
							}else{
								$dat1bw['issue'] = $startbw."-".$midbw;
								$nyibw = explode("-",$dat1bw['issue']);
							}
						}else{
							$dat1bw['issue'] = $startbw."-".$endbw;
							$nyibw = explode("-",$dat1bw['issue']);
						}
						$numbersbw = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numbersbw);
						//array_slice 取该数组中的某一段
						$numbw = 5;
						$resultbw = array_slice($numbersbw, 0, $numbw);
						$dat1bw['he'] = implode(",", $resultbw);
						$dat1bw['status'] = "等待开奖";
						M("jihua_ssc_bw")->add($dat1bw);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_ssc_bw")->where("id = '{$resbw['id']}'")->save(array("status"=>$cc4));
				if($bs==$cobw-1){
					M("jihua_ssc_bw")->where("id = '{$resbw['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newbw[$bs]+1;
					$mid4 = $newbw[$bs]+2;
					$end4 = $newbw[$bs]+3;
					$di4 = "120";
					if(substr($newbw[$bs],-3)!=$di4){
						if(substr($start4,-3) <= $di4){
							if(substr($end4,-3) > $di4){
								if(substr($mid4,-3) > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_ssc_bw")->add($dat14);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//千位
		$resqw = M("jihua_ssc_qw")->where("is_do = 0")->find();
		if($resqw){
			if(strpos($rescq['issue'],"-")){
				$narqw = explode("-",$resqw['issue']);
				$newqw = array();
				for($i = $narqw[0];$i<=$narqw[1];$i++){
					$newqw[] = $i;
				}
			}else{
				$newqw[] = trim($resqw['issue']);
			}
			$coqw = count($newqw);
			foreach($newqw as $kqw=>$vqw){
				$staqw = array();
				if($vqw == $arrcq[0]['expect']){
					$hsqw = explode(",",rtrim($resqw['he']));
					if(in_array($arrcq[0]['ocode']['1'],$hsqw)){
						$is_z = 1;
						$bs = $kqw;
						break;
					}else{
						$is_z = 2;
						$bs = $kqw;
						break;
					}
				}
			}
			//处理
			if($is_z == 1){
				if($bs==0){
					$ccqw = "当前中出";
				}else if($bs==1){
					$ccqw = "2期中出";
				}else{
					$ccqw = "3期中出";
				}
				M("jihua_ssc_qw")->where("id = '{$resqw['id']}'")->save(array("status"=>$ccqw,"is_do"=>1));
				$startqw = $newqw[$bs]+1;
				$midqw = $newqw[$bs]+2;
				$endqw = $newqw[$bs]+3;
				$diqw = "120";
				if(substr($newqw[$bs],-3)!=$diqw){
					if(substr($startqw,-3) <= $diqw){
						if(substr($endqw,-3) > $diqw){
							if(substr($midqw,-3) > $diqw){
								$dat1qw['issue'] = $startqw;
							}else{
								$dat1qw['issue'] = $startqw."-".$midqw;
								$nyiqw = explode("-",$dat1qw['issue']);
							}
						}else{
							$dat1qw['issue'] = $startqw."-".$endqw;
							$nyiqw = explode("-",$dat1qw['issue']);
						}
						$numbersqw = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numbersqw);
						//array_slice 取该数组中的某一段
						$numqw = 5;
						$resultqw = array_slice($numbersqw, 0, $numqw);
						$dat1qw['he'] = implode(",", $resultqw);
						$dat1qw['status'] = "等待开奖";
						M("jihua_ssc_qw")->add($dat1qw);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_ssc_qw")->where("id = '{$resqw['id']}'")->save(array("status"=>$cc4));
				if($bs==$coqw-1){
					M("jihua_ssc_qw")->where("id = '{$resqw['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newqw[$bs]+1;
					$mid4 = $newqw[$bs]+2;
					$end4 = $newqw[$bs]+3;
					$di4 = "120";
					if(substr($newqw[$bs],-3)!=$di4){
						if(substr($start4,-3) <= $di4){
							if(substr($end4,-3) > $di4){
								if(substr($mid4,-3) > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_ssc_qw")->add($dat14);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//万位
		$resww = M("jihua_ssc_ww")->where("is_do = 0")->find();
		if($resww){
			if(strpos($rescq['issue'],"-")){
				$narww = explode("-",$resww['issue']);
				$newww = array();
				for($i = $narww[0];$i<=$narww[1];$i++){
					$newww[] = $i;
				}
			}else{
				$newww[] = trim($resww['issue']);
			}
			$coww = count($newww);
			foreach($newww as $kww=>$vww){
				$staww = array();
				if($vww == $arrcq[0]['expect']){
					$hsww = explode(",",rtrim($resww['he']));
					if(in_array($arrcq[0]['ocode']['0'],$hsww)){
						$is_z = 1;
						$bs = $kww;
						break;
					}else{
						$is_z = 2;
						$bs = $kww;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccww = "当前中出";
				}else if($bs==1){
					$ccww = "2期中出";
				}else{
					$ccww = "3期中出";
				}
				M("jihua_ssc_ww")->where("id = '{$resww['id']}'")->save(array("status"=>$ccww,"is_do"=>1));
				$startww = $newww[$bs]+1;
				$midww = $newww[$bs]+2;
				$endww = $newww[$bs]+3;
				$diww = "120";
				if(substr($newww[$bs],-3)!=$diww){
					if(substr($startww,-3) <= $diww){
						if(substr($endww,-3) > $diww){
							if(substr($midww,-3) > $diww){
								$dat1ww['issue'] = $startww;
							}else{
								$dat1ww['issue'] = $startww."-".$midww;
								$nyiww = explode("-",$dat1ww['issue']);
							}
						}else{
							$dat1ww['issue'] = $startww."-".$endww;
							$nyiww = explode("-",$dat1ww['issue']);
						}
						$numbersww = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numbersww);
						//array_slice 取该数组中的某一段
						$numww = 5;
						$resultww = array_slice($numbersww, 0, $numww);
						$dat1ww['he'] = implode(",", $resultww);
						$dat1ww['status'] = "等待开奖";
						M("jihua_ssc_ww")->add($dat1ww);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_ssc_ww")->where("id = '{$resww['id']}'")->save(array("status"=>$cc4));
				if($bs==$coww-1){
					M("jihua_ssc_ww")->where("id = '{$resww['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newww[$bs]+1;
					$mid4 = $newww[$bs]+2;
					$end4 = $newww[$bs]+3;
					$di4 = "120";
					if(substr($newww[$bs],-3)!=$di4){
						if(substr($start4,-3) <= $di4){
							if(substr($end4,-3) > $di4){
								if(substr($mid4,-3) > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_ssc_gw")->add($dat14);
						}
					}
				}
			}
		}
	}
    //新疆时时彩追号判断  1分钟1次
	public function is_xjssc(){
		//新疆时时彩
		$arrxj = $this->get_data("xjssc");
		$resxj = M("jihua_xjssc_gw")->where("is_do = 0")->find();
		$bs = 0;
		$is_z = 0;
		if($resxj){
			if(strpos($resxj['issue'],"-")){
				$narxj = explode("-",$resxj['issue']);
				$newxj = array();
				for($i = $narxj[0];$i<=$narxj[1];$i++){
					$newxj[] = $i;
				}
			}else{
				$newxj[] = trim($resxj['issue']);
			}
			$coxj = count($newxj);
			foreach($newxj as $kxj=>$vxj){
				$staxj = array();
				if($vxj == $arrxj[0]['expect']){
					$hsxj = explode(",",rtrim($resxj['he']));
					$abxj = substr($vxj,-3);
					if(in_array($arrxj[0]['ocode']['4'],$hsxj)){
						$is_z = 1;
						$bs = $kxj;
						break;
					}else{
						$is_z = 2;
						$bs = $kxj;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccxj = "当前中出";
				}else if($bs==1){
					$ccxj = "2期中出";
				}else{
					$ccxj = "3期中出";
				}
				M("jihua_xjssc_gw")->where("id = '{$resxj['id']}'")->save(array("status"=>$ccxj,"is_do"=>1));
				$startxj = $newxj[$bs]+1;
				$midxj = $newxj[$bs]+2;
				$endxj = $newxj[$bs]+3;
				$dixj = "96";
				if(substr($newxj[$bs],-2)!=$dixj){
					if(substr($startxj,-2) <= $dixj){
						if(substr($endxj,-2) > $dixj){
							if(substr($midxj,-2) > $dixj){
								$dat1xj['issue'] = $startxj;
							}else{
								$dat1xj['issue'] = $startxj."-".$midxj;
								$nyixj = explode("-",$dat1xj['issue']);
							}
						}else{
							$dat1xj['issue'] = $startxj."-".$endxj;
							$nyixj = explode("-",$dat1xj['issue']);
						}
						$numbersxj = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numbersxj);
						//array_slice 取该数组中的某一段
						$numxj = 5;
						$resultxj = array_slice($numbersxj, 0, $numxj);
						$dat1xj['he'] = implode(",", $resultxj);
						$dat1xj['status'] = "等待开奖";
						M("jihua_xjssc_gw")->add($dat1xj);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_xjssc_gw")->where("id = '{$resxj['id']}'")->save(array("status"=>$cc4));
				if($bs==$coxj-1){
					M("jihua_xjssc_gw")->where("id = '{$resxj['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newxj[$bs]+1;
					$mid4 = $newxj[$bs]+2;
					$end4 = $newxj[$bs]+3;
					$di4 = "96";
					if(substr($newxj[$bs],-2)!=$di4){
						if(substr($start4,-2) <= $di4){
							if(substr($end4,-2) > $di4){
								if(substr($mid4,-2) > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_xjssc_gw")->add($dat14);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//十位
		$resxjsw = M("jihua_xjssc_sw")->where("is_do = 0")->find();
		if($resxjsw){
			if(strpos($resxj['issue'],"-")){
				$narxjsw = explode("-",$resxjsw['issue']);
				$newxjsw = array();
				for($i = $narxjsw[0];$i<=$narxjsw[1];$i++){
					$newxjsw[] = $i;
				}
			}else{
				$newxjsw[] = trim($resxjsw['issue']);
			}
			$coxjsw = count($newxjsw);
			foreach($newxjsw as $kxjsw=>$vxjsw){
				$staxjsw = array();
				if($vxjsw == $arrxj[0]['expect']){
					$hsxjsw = explode(",",rtrim($resxjsw['he']));
					if(in_array($arrxj[0]['ocode']['3'],$hsxjsw)){
						$is_z = 1;
						$bs = $kxjsw;
						break;
					}else{
						$is_z = 2;
						$bs = $kxjsw;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccxjsw = "当前中出";
				}else if($bs==1){
					$ccxjsw = "2期中出";
				}else{
					$ccxjsw = "3期中出";
				}
				M("jihua_xjssc_sw")->where("id = '{$resxjsw['id']}'")->save(array("status"=>$ccxjsw,"is_do"=>1));
				$startxjsw = $newxjsw[$bs]+1;
				$midxjsw = $newxjsw[$bs]+2;
				$endxjsw = $newxjsw[$bs]+3;
				$dixjsw = "96";
				if(substr($newxjsw[$bs],-2)!=$dixjsw){
					if(substr($startxjsw,-2) <= $dixjsw){
						if(substr($endxjsw,-2) > $dixjsw){
							if(substr($midxjsw,-2) > $dixjsw){
								$dat1xjsw['issue'] = $startxjsw;
							}else{
								$dat1xjsw['issue'] = $startxjsw."-".$midxjsw;
								$nyixjsw = explode("-",$dat1xjsw['issue']);
							}
						}else{
							$dat1xjsw['issue'] = $startxjsw."-".$endxjsw;
							$nyixjsw = explode("-",$dat1xjsw['issue']);
						}
						$numbersxjsw = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numbersxjsw);
						//array_slice 取该数组中的某一段
						$numxjsw = 5;
						$resultxjsw = array_slice($numbersxjsw, 0, $numxjsw);
						$dat1xjsw['he'] = implode(",", $resultxjsw);
						$dat1xjsw['status'] = "等待开奖";
						M("jihua_xjssc_sw")->add($dat1xjsw);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_xjssc_sw")->where("id = '{$resxjsw['id']}'")->save(array("status"=>$cc4));
				if($bs==$coxjsw-1){
					M("jihua_xjssc_sw")->where("id = '{$resxjsw['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newxjsw[$bs]+1;
					$mid4 = $newxjsw[$bs]+2;
					$end4 = $newxjsw[$bs]+3;
					$di4 = "96";
					if(substr($newxjsw[$bs],-2)!=$di4){
						if(substr($start4,-2) <= $di4){
							if(substr($end4,-2) > $di4){
								if(substr($mid4,-2) > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_xjssc_sw")->add($dat14);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//百位
		$resxjbw = M("jihua_xjssc_bw")->where("is_do = 0")->find();
		if($resxjbw){
			if(strpos($resxj['issue'],"-")){
				$narxjbw = explode("-",$resxjbw['issue']);
				$newxjbw = array();
				for($i = $narxjbw[0];$i<=$narxjbw[1];$i++){
					$newxjbw[] = $i;
				}
			}else{
				$newxjbw[] = trim($resxjbw['issue']);
			}
			$coxjbw = count($newxjbw);
			foreach($newxjbw as $kxjbw=>$vxjbw){
				$staxjbw = array();
				if($vxjbw == $arrxj[0]['expect']){
					$hsxjbw = explode(",",rtrim($resxjbw['he']));
					if(in_array($arrxj[0]['ocode']['2'],$hsxjbw)){
						$is_z = 1;
						$bs = $kxjbw;
						break;
					}else{
						$is_z = 2;
						$bs = $kxjbw;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccxjbw = "当前中出";
				}else if($bs==1){
					$ccxjbw = "2期中出";
				}else{
					$ccxjbw = "3期中出";
				}
				M("jihua_xjssc_bw")->where("id = '{$resxjbw['id']}'")->save(array("status"=>$ccxjbw,"is_do"=>1));
				$startxjbw = $newxjbw[$bs]+1;
				$midxjbw = $newxjbw[$bs]+2;
				$endxjbw = $newxjbw[$bs]+3;
				$dixjbw = "96";
				if(substr($newxjbw[$bs],-2)!=$dixjbw){
					if(substr($startxjbw,-2) <= $dixjbw){
						if(substr($endxjbw,-2) > $dixjbw){
							if(substr($midxjbw,-2) > $dixjbw){
								$dat1xjbw['issue'] = $startxjbw;
							}else{
								$dat1xjbw['issue'] = $startxjbw."-".$midxjbw;
								$nyixjbw = explode("-",$dat1xjbw['issue']);
							}
						}else{
							$dat1xjbw['issue'] = $startxjbw."-".$endxjbw;
							$nyixjbw = explode("-",$dat1xjbw['issue']);
						}
						$numbersxjbw = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numbersxjbw);
						//array_slice 取该数组中的某一段
						$numxjbw = 5;
						$resultxjbw = array_slice($numbersxjbw, 0, $numxjbw);
						$dat1xjbw['he'] = implode(",", $resultxjbw);
						$dat1xjbw['status'] = "等待开奖";
						M("jihua_xjssc_bw")->add($dat1xjbw);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_xjssc_bw")->where("id = '{$resxjbw['id']}'")->save(array("status"=>$cc4));
				if($bs==$coxjbw-1){
					M("jihua_xjssc_bw")->where("id = '{$resxjbw['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newxjbw[$bs]+1;
					$mid4 = $newxjbw[$bs]+2;
					$end4 = $newxjbw[$bs]+3;
					$di4 = "96";
					if(substr($newxjbw[$bs],-2)!=$di4){
						if(substr($start4,-2) <= $di4){
							if(substr($end4,-2) > $di4){
								if(substr($mid4,-2) > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_xjssc_bw")->add($dat14);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//千位
		$resxjqw = M("jihua_xjssc_qw")->where("is_do = 0")->find();
		if($resxjqw){
			if(strpos($resxj['issue'],"-")){
				$narxjqw = explode("-",$resxjqw['issue']);
				$newxjqw = array();
				for($i = $narxjqw[0];$i<=$narxjqw[1];$i++){
					$newxjqw[] = $i;
				}
			}else{
				$newxjqw[] = trim($resxjqw['issue']);
			}
			$coxjqw = count($newxjqw);
			foreach($newxjqw as $kxjqw=>$vxjqw){
				$staxjqw = array();
				if($vxjqw == $arrxj[0]['expect']){
					$hsxjqw = explode(",",rtrim($resxjqw['he']));
					if(in_array($arrxj[0]['ocode']['1'],$hsxjqw)){
						$is_z = 1;
						$bs = $kxjqw;
						break;
					}else{
						$is_z = 2;
						$bs = $kxjqw;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccxjqw = "当前中出";
				}else if($bs==1){
					$ccxjqw = "2期中出";
				}else{
					$ccxjqw = "3期中出";
				}
				M("jihua_xjssc_qw")->where("id = '{$resxjqw['id']}'")->save(array("status"=>$ccxjqw,"is_do"=>1));
				$startxjqw = $newxjqw[$bs]+1;
				$midxjqw = $newxjqw[$bs]+2;
				$endxjqw = $newxjqw[$bs]+3;
				$dixjqw = "96";
				if(substr($newxjqw[$bs],-2)!=$dixjqw){
					if(substr($startxjqw,-2) <= $dixjqw){
						if(substr($endxjqw,-2) > $dixjqw){
							if(substr($midxjqw,-2) > $dixjqw){
								$dat1xjqw['issue'] = $startxjqw;
							}else{
								$dat1xjqw['issue'] = $startxjqw."-".$midxjqw;
								$nyixjqw = explode("-",$dat1xjqw['issue']);
							}
						}else{
							$dat1xjqw['issue'] = $startxjqw."-".$endxjqw;
							$nyixjqw = explode("-",$dat1xjqw['issue']);
						}
						$numbersxjqw = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numbersxjqw);
						//array_slice 取该数组中的某一段
						$numxjqw = 5;
						$resultxjqw = array_slice($numbersxjqw, 0, $numxjqw);
						$dat1xjqw['he'] = implode(",", $resultxjqw);
						$dat1xjqw['status'] = "等待开奖";
						M("jihua_xjssc_qw")->add($dat1xjqw);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_xjssc_qw")->where("id = '{$resxjqw['id']}'")->save(array("status"=>$cc4));
				if($bs==$coxjqw-1){
					M("jihua_xjssc_qw")->where("id = '{$resxjqw['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newxjqw[$bs]+1;
					$mid4 = $newxjqw[$bs]+2;
					$end4 = $newxjqw[$bs]+3;
					$di4 = "96";
					if(substr($newxjqw[$bs],-2)!=$di4){
						if(substr($start4,-2) <= $di4){
							if(substr($end4,-2) > $di4){
								if(substr($mid4,-2) > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_xjssc_qw")->add($dat14);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//万位
		$resxjww = M("jihua_xjssc_ww")->where("is_do = 0")->find();
		if($resxjww){
			if(strpos($resxj['issue'],"-")){
				$narxjww = explode("-",$resxjww['issue']);
				$nexjwww = array();
				for($i = $narxjww[0];$i<=$narxjww[1];$i++){
					$nexjwww[] = $i;
				}
			}else{
				$nexjwww[] = trim($resxjww['issue']);
			}
			$coxjww = count($nexjwww);
			foreach($nexjwww as $kxjww=>$vxjww){
				$staxjww = array();
				if($vxjww == $arrxj[0]['expect']){
					$hsxjww = explode(",",rtrim($resxjww['he']));
					if(in_array($arrxj[0]['ocode']['0'],$hsxjww)){
						$is_z = 1;
						$bs = $kxjww;
						break;
					}else{
						$is_z = 2;
						$bs = $kxjww;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccxjww = "当前中出";
				}else if($bs==1){
					$ccxjww = "2期中出";
				}else{
					$ccxjww = "3期中出";
				}
				M("jihua_xjssc_ww")->where("id = '{$resxjww['id']}'")->save(array("status"=>$ccxjww,"is_do"=>1));
				$startxjww = $nexjwww[$bs]+1;
				$midxjww = $nexjwww[$bs]+2;
				$endxjww = $nexjwww[$bs]+3;
				$dixjww = "96";
				if(substr($nexjwww[$bs],-2)!=$dixjww){
					if(substr($startxjww,-2) <= $dixjww){
						if(substr($endxjww,-2) > $dixjww){
							if(substr($midxjww,-2) > $dixjww){
								$dat1xjww['issue'] = $startxjww;
							}else{
								$dat1xjww['issue'] = $startxjww."-".$midxjww;
								$nyixjww = explode("-",$dat1xjww['issue']);
							}
						}else{
							$dat1xjww['issue'] = $startxjww."-".$endxjww;
							$nyixjww = explode("-",$dat1xjww['issue']);
						}
						$numbersxjww = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numbersxjww);
						//array_slice 取该数组中的某一段
						$numxjww = 5;
						$resultxjww = array_slice($numbersxjww, 0, $numxjww);
						$dat1xjww['he'] = implode(",", $resultxjww);
						$dat1xjww['status'] = "等待开奖";
						M("jihua_xjssc_ww")->add($dat1xjww);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_xjssc_ww")->where("id = '{$resxjww['id']}'")->save(array("status"=>$cc4));
				if($bs==$coxjww-1){
					M("jihua_xjssc_ww")->where("id = '{$resxjww['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $nexjwww[$bs]+1;
					$mid4 = $nexjwww[$bs]+2;
					$end4 = $nexjwww[$bs]+3;
					$di4 = "96";
					if(substr($nexjwww[$bs],-2)!=$di4){
						if(substr($start4,-2) <= $di4){
							if(substr($end4,-2) > $di4){
								if(substr($mid4,-2) > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_xjssc_ww")->add($dat14);
						}
					}
				}
			}
		}
	}
    //天津时时彩追号判断  1分钟1次
	public function is_tjssc(){
		//天津时时彩
		$arrtj = $this->get_data("tjssc");
		$restj = M("jihua_tjssc_gw")->where("is_do = 0")->find();
		$bs = 0;
		$is_z = 0;
		if($restj){
			if(strpos($restj['issue'],"-")){
				$nartj = explode("-",$restj['issue']);
				$newtj = array();
				for($i = $nartj[0];$i<=$nartj[1];$i++){
					$newtj[] = $i;
				}
			}else{
				$newtj[] = trim($restj['issue']);
			}
			$cotj = count($newtj);
			foreach($newtj as $ktj=>$vtj){
				$statj = array();
				if($vtj == $arrtj[0]['expect']){
					$hstj = explode(",",rtrim($restj['he']));
					$abtj = substr($vtj,-3);
					if(in_array($arrtj[0]['ocode']['4'],$hstj)){
						$is_z = 1;
						$bs = $ktj;
						break;
					}else{
						$is_z = 2;
						$bs = $ktj;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$cctj = "当前中出";
				}else if($bs==1){
					$cctj = "2期中出";
				}else{
					$cctj = "3期中出";
				}
				M("jihua_tjssc_gw")->where("id = '{$restj['id']}'")->save(array("status"=>$cctj,"is_do"=>1));
				$starttj = $newtj[$bs]+1;
				$midtj = $newtj[$bs]+2;
				$endtj = $newtj[$bs]+3;
				$ditj = date("Ymd")."084";
				if($newtj[$bs]!=$ditj){
					if($starttj <= $ditj){
						if($endtj > $ditj){
							if($midtj > $ditj){
								$dat1tj['issue'] = $starttj;
							}else{
								$dat1tj['issue'] = $starttj."-".$midtj;
								$nyitj = explode("-",$dat1tj['issue']);
							}
						}else{
							$dat1tj['issue'] = $starttj."-".$endtj;
							$nyitj = explode("-",$dat1tj['issue']);
						}
						$numberstj = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numberstj);
						//array_slice 取该数组中的某一段
						$numtj = 5;
						$resulttj = array_slice($numberstj, 0, $numtj);
						$dat1tj['he'] = implode(",", $resulttj);
						$dat1tj['status'] = "等待开奖";
						M("jihua_tjssc_gw")->add($dat1tj);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_tjssc_gw")->where("id = '{$restj['id']}'")->save(array("status"=>$cc4));
				if($bs==$cotj-1){
					M("jihua_tjssc_gw")->where("id = '{$restj['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newtj[$bs]+1;
					$mid4 = $newtj[$bs]+2;
					$end4 = $newtj[$bs]+3;
					$di4 = date("Ymd")."084";
					if($newtj[$bs]!=$di4){
						if($start4 <= $di4){
							if($end4 > $di4){
								if($mid4 > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_tjssc_gw")->add($dat14);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//十位
		$restjsw = M("jihua_tjssc_sw")->where("is_do = 0")->find();
		if($restjsw){
			if(strpos($restj['issue'],"-")){
				$nartjsw = explode("-",$restjsw['issue']);
				$newtjsw = array();
				for($i = $nartjsw[0];$i<=$nartjsw[1];$i++){
					$newtjsw[] = $i;
				}
			}else{
				$newtjsw[] = trim($restjsw['issue']);
			}
			$cotjsw = count($newtjsw);
			foreach($newtjsw as $ktjsw=>$vtjsw){
				$statjsw = array();
				if($vtjsw == $arrtj[0]['expect']){
					$hstjsw = explode(",",rtrim($restjsw['he']));
					if(in_array($arrtj[0]['ocode']['3'],$hstjsw)){
						$is_z = 1;
						$bs = $ktjsw;
						break;
					}else{
						$is_z = 2;
						$bs = $ktjsw;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$cctjsw = "当前中出";
				}else if($bs==1){
					$cctjsw = "2期中出";
				}else{
					$cctjsw = "3期中出";
				}
				M("jihua_tjssc_sw")->where("id = '{$restjsw['id']}'")->save(array("status"=>$cctjsw,"is_do"=>1));
				$starttjsw = $newtjsw[$bs]+1;
				$midtjsw = $newtjsw[$bs]+2;
				$endtjsw = $newtjsw[$bs]+3;
				$ditjsw = date("Ymd")."084";
				if($newtjsw[$bs]!=$ditjsw){
					if($starttjsw <= $ditjsw){
						if($endtjsw > $ditjsw){
							if($midtjsw > $ditjsw){
								$dat1tjsw['issue'] = $starttjsw;
							}else{
								$dat1tjsw['issue'] = $starttjsw."-".$midtjsw;
								$nyitjsw = explode("-",$dat1tjsw['issue']);
							}
						}else{
							$dat1tjsw['issue'] = $starttjsw."-".$endtjsw;
							$nyitjsw = explode("-",$dat1tjsw['issue']);
						}
						$numberstjsw = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numberstjsw);
						//array_slice 取该数组中的某一段
						$numtjsw = 5;
						$resulttjsw = array_slice($numberstjsw, 0, $numtjsw);
						$dat1tjsw['he'] = implode(",", $resulttjsw);
						$dat1tjsw['status'] = "等待开奖";
						M("jihua_tjssc_sw")->add($dat1tjsw);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_tjssc_sw")->where("id = '{$restjsw['id']}'")->save(array("status"=>$cc4));
				if($bs==$cotjsw-1){
					M("jihua_tjssc_sw")->where("id = '{$restjsw['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newtjsw[$bs]+1;
					$mid4 = $newtjsw[$bs]+2;
					$end4 = $newtjsw[$bs]+3;
					$di4 = date("Ymd")."084";
					if($newtjsw[$bs]!=$di4){
						if($start4 <= $di4){
							if($end4 > $di4){
								if($mid4 > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_tjssc_sw")->add($dat14);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//百位
		$restjbw = M("jihua_tjssc_bw")->where("is_do = 0")->find();
		if($restjbw){
			if(strpos($restj['issue'],"-")){
				$nartjbw = explode("-",$restjbw['issue']);
				$newtjbw = array();
				for($i = $nartjbw[0];$i<=$nartjbw[1];$i++){
					$newtjbw[] = $i;
				}
			}else{
				$newtjbw[] = trim($restjbw['issue']);
			}
			$cotjbw = count($newtjbw);
			foreach($newtjbw as $ktjbw=>$vtjbw){
				$statjbw = array();
				if($vtjbw == $arrtj[0]['expect']){
					$hstjbw = explode(",",rtrim($restjbw['he']));
					if(in_array($arrtj[0]['ocode']['2'],$hstjbw)){
						$is_z = 1;
						$bs = $ktjbw;
						break;
					}else{
						$is_z = 2;
						$bs = $ktjbw;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$cctjbw = "当前中出";
				}else if($bs==1){
					$cctjbw = "2期中出";
				}else{
					$cctjbw = "3期中出";
				}
				M("jihua_tjssc_bw")->where("id = '{$restjbw['id']}'")->save(array("status"=>$cctjbw,"is_do"=>1));
				$starttjbw = $newtjbw[$bs]+1;
				$midtjbw = $newtjbw[$bs]+2;
				$endtjbw = $newtjbw[$bs]+3;
				$ditjbw = date("Ymd")."084";
				if($newtjbw[$bs]!=$ditjbw){
					if($starttjbw <= $ditjbw){
						if($endtjbw > $ditjbw){
							if($midtjbw > $ditjbw){
								$dat1tjbw['issue'] = $starttjbw;
							}else{
								$dat1tjbw['issue'] = $starttjbw."-".$midtjbw;
								$nyitjbw = explode("-",$dat1tjbw['issue']);
							}
						}else{
							$dat1tjbw['issue'] = $starttjbw."-".$endtjbw;
							$nyitjbw = explode("-",$dat1tjbw['issue']);
						}
						$numberstjbw = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numberstjbw);
						//array_slice 取该数组中的某一段
						$numtjbw = 5;
						$resulttjbw = array_slice($numberstjbw, 0, $numtjbw);
						$dat1tjbw['he'] = implode(",", $resulttjbw);
						$dat1tjbw['status'] = "等待开奖";
						M("jihua_tjssc_bw")->add($dat1tjbw);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_tjssc_bw")->where("id = '{$restjbw['id']}'")->save(array("status"=>$cc4));
				if($bs==$cotjbw-1){
					M("jihua_tjssc_bw")->where("id = '{$restjbw['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newtjbw[$bs]+1;
					$mid4 = $newtjbw[$bs]+2;
					$end4 = $newtjbw[$bs]+3;
					$di4 = date("Ymd")."084";
					if($newtjbw[$bs]!=$di4){
						if($start4 <= $di4){
							if($end4 > $di4){
								if($mid4 > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_tjssc_bw")->add($dat14);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//千位
		$restjqw = M("jihua_tjssc_qw")->where("is_do = 0")->find();
		if($restjqw){
			if(strpos($restj['issue'],"-")){
				$nartjqw = explode("-",$restjqw['issue']);
				$newtjqw = array();
				for($i = $nartjqw[0];$i<=$nartjqw[1];$i++){
					$newtjqw[] = $i;
				}
			}else{
				$newtjqw[] = trim($restjqw['issue']);
			}
			$cotjqw = count($newtjqw);
			foreach($newtjqw as $ktjqw=>$vtjqw){
				$statjqw = array();
				if($vtjqw == $arrtj[0]['expect']){
					$hstjqw = explode(",",rtrim($restjqw['he']));
					if(in_array($arrtj[0]['ocode']['1'],$hstjqw)){
						$is_z = 1;
						$bs = $ktjqw;
						break;
					}else{
						$is_z = 2;
						$bs = $ktjqw;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$cctjqw = "当前中出";
				}else if($bs==1){
					$cctjqw = "2期中出";
				}else{
					$cctjqw = "3期中出";
				}
				M("jihua_tjssc_qw")->where("id = '{$restjqw['id']}'")->save(array("status"=>$cctjqw,"is_do"=>1));
				$starttjqw = $newtjqw[$bs]+1;
				$midtjqw = $newtjqw[$bs]+2;
				$endtjqw = $newtjqw[$bs]+3;
				$ditjqw = date("Ymd")."084";
				if($newtjqw[$bs]!=$ditjqw){
					if($starttjqw <= $ditjqw){
						if($endtjqw > $ditjqw){
							if($midtjqw > $ditjqw){
								$dat1tjqw['issue'] = $starttjqw;
							}else{
								$dat1tjqw['issue'] = $starttjqw."-".$midtjqw;
								$nyitjqw = explode("-",$dat1tjqw['issue']);
							}
						}else{
							$dat1tjqw['issue'] = $starttjqw."-".$endtjqw;
							$nyitjqw = explode("-",$dat1tjqw['issue']);
						}
						$numberstjqw = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numberstjqw);
						//array_slice 取该数组中的某一段
						$numtjqw = 5;
						$resulttjqw = array_slice($numberstjqw, 0, $numtjqw);
						$dat1tjqw['he'] = implode(",", $resulttjqw);
						$dat1tjqw['status'] = "等待开奖";
						M("jihua_tjssc_qw")->add($dat1tjqw);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_tjssc_qw")->where("id = '{$restjqw['id']}'")->save(array("status"=>$cc4));
				if($bs==$cotjqw-1){
					M("jihua_tjssc_qw")->where("id = '{$restjqw['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newtjqw[$bs]+1;
					$mid4 = $newtjqw[$bs]+2;
					$end4 = $newtjqw[$bs]+3;
					$di4 = date("Ymd")."084";
					if($newtjqw[$bs]!=$di4){
						if($start4 <= $di4){
							if($end4 > $di4){
								if($mid4 > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_tjssc_qw")->add($dat14);
						}
					}
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//万位
		$restjww = M("jihua_tjssc_ww")->where("is_do = 0")->find();
		if($restjww){
			if(strpos($restj['issue'],"-")){
				$nartjww = explode("-",$restjww['issue']);
				$netjwww = array();
				for($i = $nartjww[0];$i<=$nartjww[1];$i++){
					$netjwww[] = $i;
				}
			}else{
				$netjwww[] = trim($restjww['issue']);
			}
			$cotjww = count($netjwww);
			foreach($netjwww as $ktjww=>$vtjww){
				$statjww = array();
				if($vtjww == $arrtj[0]['expect']){
					$hstjww = explode(",",rtrim($restjww['he']));
					if(in_array($arrtj[0]['ocode']['0'],$hstjww)){
						$is_z = 1;
						$bs = $ktjww;
						break;
					}else{
						$is_z = 2;
						$bs = $ktjww;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$cctjww = "当前中出";
				}else if($bs==1){
					$cctjww = "2期中出";
				}else{
					$cctjww = "3期中出";
				}
				M("jihua_tjssc_ww")->where("id = '{$restjww['id']}'")->save(array("status"=>$cctjww,"is_do"=>1));
				$starttjww = $netjwww[$bs]+1;
				$midtjww = $netjwww[$bs]+2;
				$endtjww = $netjwww[$bs]+3;
				$ditjww = date("Ymd")."084";
				if($netjwww[$bs]!=$ditjww){
					if($starttjww <= $ditjww){
						if($endtjww > $ditjww){
							if($midtjww > $ditjww){
								$dat1tjww['issue'] = $starttjww;
							}else{
								$dat1tjww['issue'] = $starttjww."-".$midtjww;
								$nyitjww = explode("-",$dat1tjww['issue']);
							}
						}else{
							$dat1tjww['issue'] = $starttjww."-".$endtjww;
							$nyitjww = explode("-",$dat1tjww['issue']);
						}
						$numberstjww = range(0, 9);
						//shuffle 将数组顺序随即打乱
						shuffle($numberstjww);
						//array_slice 取该数组中的某一段
						$numtjww = 5;
						$resulttjww = array_slice($numberstjww, 0, $numtjww);
						$dat1tjww['he'] = implode(",", $resulttjww);
						$dat1tjww['status'] = "等待开奖";
						M("jihua_tjssc_ww")->add($dat1tjww);
					}
				}
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_tjssc_ww")->where("id = '{$restjww['id']}'")->save(array("status"=>$cc4));
				if($bs==$cotjww-1){
					M("jihua_tjssc_ww")->where("id = '{$restjww['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $netjwww[$bs]+1;
					$mid4 = $netjwww[$bs]+2;
					$end4 = $netjwww[$bs]+3;
					$di4 = date("Ymd")."084";
					if($netjwww[$bs]!=$di4){
						if($start4 <= $di4){
							if($end4 > $di4){
								if($mid4 > $di4){
									$dat14['issue'] = $start4;
								}else{
									$dat14['issue'] = $start4."-".$mid4;
									$nyi4 = explode("-",$dat14['issue']);
								}
							}else{
								$dat14['issue'] = $start4."-".$end4;
								$nyi4 = explode("-",$dat14['issue']);
							}
							$numbers4 = range(0, 9);
							//shuffle 将数组顺序随即打乱
							shuffle($numbers4);
							//array_slice 取该数组中的某一段
							$num4 = 5;
							$result4 = array_slice($numbers4, 0, $num4);
							$dat14['he'] = implode(",", $result4);
							$dat14['status'] = "等待开奖";
							M("jihua_tjssc_ww")->add($dat14);
						}
					}
				}
			}
		}
	}
    //埃及二分彩追号判断  1分钟1次
	public function is_ssc(){
		//埃及二分彩
		$arraj = $this->get_data("ffc2");
		$resaj = M("jihua_ajssc_gw")->where("is_do = 0")->find();
		$bs = 0;
		$is_z = 0;
		if($resaj){
			if(strpos($resaj['issue'],"-")){
				$naraj = explode("-",$resaj['issue']);
				$newaj = array();
				for($i = $naraj[0];$i<=$naraj[1];$i++){
					$newaj[] = $i;
				}
			}else{
				$newaj[] = trim($resaj['issue']);
			}
			$coaj = count($newaj);
			foreach($newaj as $kaj=>$vaj){
				$staaj = array();
				if($vaj == $arraj[0]['expect']){
					$hsaj = explode(",",rtrim($resaj['he']));
					$abaj = substr($vaj,-3);
					if(in_array($arraj[0]['ocode']['4'],$hsaj)){
						$is_z = 1;
						$bs = $kaj;
						break;
					}else{
						$is_z = 2;
						$bs = $kaj;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccaj = "当前中出";
				}else if($bs==1){
					$ccaj = "2期中出";
				}else{
					$ccaj = "3期中出";
				}
				M("jihua_ajssc_gw")->where("id = '{$resaj['id']}'")->save(array("status"=>$ccaj,"is_do"=>1));
				$startaj = $newaj[$bs]+1;
				$midaj = $newaj[$bs]+2;
				$endaj = $newaj[$bs]+3;
				$dat1aj['issue'] = $startaj."-".$endaj;
				$nyiaj = explode("-",$dat1aj['issue']);
				$numbersaj = range(0, 9);
				//shuffle 将数组顺序随即打乱
				shuffle($numbersaj);
				//array_slice 取该数组中的某一段
				$numaj = 5;
				$resultaj = array_slice($numbersaj, 0, $numaj);
				$dat1aj['he'] = implode(",", $resultaj);
				$dat1aj['status'] = "等待开奖";
				M("jihua_ajssc_gw")->add($dat1aj);
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_ajssc_gw")->where("id = '{$resaj['id']}'")->save(array("status"=>$cc4));
				if($bs==$coaj-1){
					M("jihua_ajssc_gw")->where("id = '{$resaj['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newaj[$bs]+1;
					$mid4 = $newaj[$bs]+2;
					$end4 = $newaj[$bs]+3;
					$dat14['issue'] = $start4."-".$end4;
					$nyi4 = explode("-",$dat14['issue']);
					$numbers4 = range(0, 9);
					//shuffle 将数组顺序随即打乱
					shuffle($numbers4);
					//array_slice 取该数组中的某一段
					$num4 = 5;
					$result4 = array_slice($numbers4, 0, $num4);
					$dat14['he'] = implode(",", $result4);
					$dat14['status'] = "等待开奖";
					M("jihua_ajssc_gw")->add($dat14);
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//十位
		$resajsw = M("jihua_ajssc_sw")->where("is_do = 0")->find();
		if($resajsw){
			if(strpos($resaj['issue'],"-")){
				$narajsw = explode("-",$resajsw['issue']);
				$newajsw = array();
				for($i = $narajsw[0];$i<=$narajsw[1];$i++){
					$newajsw[] = $i;
				}
			}else{
				$newajsw[] = trim($resajsw['issue']);
			}
			$coajsw = count($newajsw);
			foreach($newajsw as $kajsw=>$vajsw){
				$staajsw = array();
				if($vajsw == $arraj[0]['expect']){
					$hsajsw = explode(",",rtrim($resajsw['he']));
					if(in_array($arraj[0]['ocode']['3'],$hsajsw)){
						$is_z = 1;
						$bs = $kajsw;
						break;
					}else{
						$is_z = 2;
						$bs = $kajsw;
						break;
					}
				}
			}	
			if($is_z == 1){
				if($bs==0){
					$ccajsw = "当前中出";
				}else if($bs==1){
					$ccajsw = "2期中出";
				}else{
					$ccajsw = "3期中出";
				}
				M("jihua_ajssc_sw")->where("id = '{$resajsw['id']}'")->save(array("status"=>$ccajsw,"is_do"=>1));
				$startajsw = $newajsw[$bs]+1;
				$midajsw = $newajsw[$bs]+2;
				$endajsw = $newajsw[$bs]+3;
				$dat1ajsw['issue'] = $startajsw."-".$endajsw;
				$nyiajsw = explode("-",$dat1ajsw['issue']);
				$numbersajsw = range(0, 9);
				//shuffle 将数组顺序随即打乱
				shuffle($numbersajsw);
				//array_slice 取该数组中的某一段
				$numajsw = 5;
				$resultajsw = array_slice($numbersajsw, 0, $numajsw);
				$dat1ajsw['he'] = implode(",", $resultajsw);
				$dat1ajsw['status'] = "等待开奖";
				M("jihua_ajssc_sw")->add($dat1ajsw);
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_ajssc_sw")->where("id = '{$resajsw['id']}'")->save(array("status"=>$cc4));
				if($bs==$coajsw-1){
					M("jihua_ajssc_sw")->where("id = '{$resajsw['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newajsw[$bs]+1;
					$mid4 = $newajsw[$bs]+2;
					$end4 = $newajsw[$bs]+3;
					$dat14['issue'] = $start4."-".$end4;
					$nyi4 = explode("-",$dat14['issue']);
					$numbers4 = range(0, 9);
					//shuffle 将数组顺序随即打乱
					shuffle($numbers4);
					//array_slice 取该数组中的某一段
					$num4 = 5;
					$result4 = array_slice($numbers4, 0, $num4);
					$dat14['he'] = implode(",", $result4);
					$dat14['status'] = "等待开奖";
					M("jihua_ajssc_sw")->add($dat14);
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//百位
		$resajbw = M("jihua_ajssc_bw")->where("is_do = 0")->find();
		if($resajbw){
			if(strpos($resaj['issue'],"-")){
				$narajbw = explode("-",$resajbw['issue']);
				$newajbw = array();
				for($i = $narajbw[0];$i<=$narajbw[1];$i++){
					$newajbw[] = $i;
				}
			}else{
				$newajbw[] = trim($resajbw['issue']);
			}
			$coajbw = count($newajbw);
			foreach($newajbw as $kajbw=>$vajbw){
				$staajbw = array();
				if($vajbw == $arraj[0]['expect']){
					$hsajbw = explode(",",rtrim($resajbw['he']));
					if(in_array($arraj[0]['ocode']['2'],$hsajbw)){
						$is_z = 1;
						$bs = $kajbw;
						break;
					}else{
						$is_z = 2;
						$bs = $kajbw;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccajbw = "当前中出";
				}else if($bs==1){
					$ccajbw = "2期中出";
				}else{
					$ccajbw = "3期中出";
				}
				M("jihua_ajssc_bw")->where("id = '{$resajbw['id']}'")->save(array("status"=>$ccajbw,"is_do"=>1));
				$startajbw = $newajbw[$bs]+1;
				$midajbw = $newajbw[$bs]+2;
				$endajbw = $newajbw[$bs]+3;
				$dat1ajbw['issue'] = $startajbw."-".$endajbw;
				$nyiajbw = explode("-",$dat1ajbw['issue']);
				$numbersajbw = range(0, 9);
				//shuffle 将数组顺序随即打乱
				shuffle($numbersajbw);
				//array_slice 取该数组中的某一段
				$numajbw = 5;
				$resultajbw = array_slice($numbersajbw, 0, $numajbw);
				$dat1ajbw['he'] = implode(",", $resultajbw);
				$dat1ajbw['status'] = "等待开奖";
				M("jihua_ajssc_bw")->add($dat1ajbw);	
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_ajssc_bw")->where("id = '{$resajbw['id']}'")->save(array("status"=>$cc4));
				if($bs==$coajbw-1){
					M("jihua_ajssc_bw")->where("id = '{$resajbw['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newajbw[$bs]+1;
					$mid4 = $newajbw[$bs]+2;
					$end4 = $newajbw[$bs]+3;
					$dat14['issue'] = $start4."-".$end4;
					$nyi4 = explode("-",$dat14['issue']);
					$numbers4 = range(0, 9);
					//shuffle 将数组顺序随即打乱
					shuffle($numbers4);
					//array_slice 取该数组中的某一段
					$num4 = 5;
					$result4 = array_slice($numbers4, 0, $num4);
					$dat14['he'] = implode(",", $result4);
					$dat14['status'] = "等待开奖";
					M("jihua_ajssc_bw")->add($dat14);
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//千位
		$resajqw = M("jihua_ajssc_qw")->where("is_do = 0")->find();
		if($resajqw){
			if(strpos($resaj['issue'],"-")){
				$narajqw = explode("-",$resajqw['issue']);
				$newajqw = array();
				for($i = $narajqw[0];$i<=$narajqw[1];$i++){
					$newajqw[] = $i;
				}
			}else{
				$newajqw[] = trim($resajqw['issue']);
			}
			$coajqw = count($newajqw);
			foreach($newajqw as $kajqw=>$vajqw){
				$staajqw = array();
				if($vajqw == $arraj[0]['expect']){
					$hsajqw = explode(",",rtrim($resajqw['he']));
					if(in_array($arraj[0]['ocode']['1'],$hsajqw)){
						$is_z = 1;
						$bs = $kajqw;
						break;
					}else{
						$is_z = 2;
						$bs = $kajqw;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccajqw = "当前中出";
				}else if($bs==1){
					$ccajqw = "2期中出";
				}else{
					$ccajqw = "3期中出";
				}
				M("jihua_ajssc_qw")->where("id = '{$resajqw['id']}'")->save(array("status"=>$ccajqw,"is_do"=>1));
				$startajqw = $newajqw[$bs]+1;
				$midajqw = $newajqw[$bs]+2;
				$endajqw = $newajqw[$bs]+3;
				$dat1ajqw['issue'] = $startajqw."-".$endajqw;
				$nyiajqw = explode("-",$dat1ajqw['issue']);
				$numbersajqw = range(0, 9);
				//shuffle 将数组顺序随即打乱
				shuffle($numbersajqw);
				//array_slice 取该数组中的某一段
				$numajqw = 5;
				$resultajqw = array_slice($numbersajqw, 0, $numajqw);
				$dat1ajqw['he'] = implode(",", $resultajqw);
				$dat1ajqw['status'] = "等待开奖";
				M("jihua_ajssc_qw")->add($dat1ajqw);
			}else if($is_z == 2){
				if($bs==0){
					$cc4 = "等待开奖";
				}else if($bs==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_ajssc_qw")->where("id = '{$resajqw['id']}'")->save(array("status"=>$cc4));
				if($bs==$coajqw-1){
					M("jihua_ajssc_qw")->where("id = '{$resajqw['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $newajqw[$bs]+1;
					$mid4 = $newajqw[$bs]+2;
					$end4 = $newajqw[$bs]+3;
					$dat14['issue'] = $start4."-".$end4;
					$nyi4 = explode("-",$dat14['issue']);
					$numbers4 = range(0, 9);
					//shuffle 将数组顺序随即打乱
					shuffle($numbers4);
					//array_slice 取该数组中的某一段
					$num4 = 5;
					$result4 = array_slice($numbers4, 0, $num4);
					$dat14['he'] = implode(",", $result4);
					$dat14['status'] = "等待开奖";
					M("jihua_ajssc_qw")->add($dat14);
				}
			}
		}
		$bs = 0;
		$is_z = 0;
		//万位
		$resajww = M("jihua_ajssc_ww")->where("is_do = 0")->find();
		if($resajww){
			if(strpos($resaj['issue'],"-")){
				$narajww = explode("-",$resajww['issue']);
				$neajwww = array();
				for($i = $narajww[0];$i<=$narajww[1];$i++){
					$neajwww[] = $i;
				}
			}else{
				$neajwww[] = trim($resajww['issue']);
			}
			$coajww = count($neajwww);
			foreach($neajwww as $kajww=>$vajww){
				$staajww = array();
				if($vajww == $arraj[0]['expect']){
					$hsajww = explode(",",rtrim($resajww['he']));
					if(in_array($arraj[0]['ocode']['0'],$hsajww)){
						$is_z = 1;
						$bs = $kajww;
						break;
					}else{
						$is_z = 2;
						$bs = $kajww;
						break;
					}
				}
			}
			if($is_z == 1){
				if($bs==0){
					$ccajww = "当前中出";
				}else if($bs==1){
					$ccajww = "2期中出";
				}else{
					$ccajww = "3期中出";
				}
				M("jihua_ajssc_ww")->where("id = '{$resajww['id']}'")->save(array("status"=>$ccajww,"is_do"=>1));
				$startajww = $neajwww[$bs]+1;
				$midajww = $neajwww[$bs]+2;
				$endajww = $neajwww[$bs]+3;
				$dat1ajww['issue'] = $startajww."-".$endajww;
				$nyiajww = explode("-",$dat1ajww['issue']);
				$numbersajww = range(0, 9);
				//shuffle 将数组顺序随即打乱
				shuffle($numbersajww);
				//array_slice 取该数组中的某一段
				$numajww = 5;
				$resultajww = array_slice($numbersajww, 0, $numajww);
				$dat1ajww['he'] = implode(",", $resultajww);
				$dat1ajww['status'] = "等待开奖";
				M("jihua_ajssc_ww")->add($dat1ajww);
			}else if($is_z == 2){
				if($kajww==0){
					$cc4 = "等待开奖";
				}else if($kajww==1){
					$cc4 = "等待开奖";
				}else{
					$cc4 = "追号失败";
				}
				M("jihua_ajssc_ww")->where("id = '{$resajww['id']}'")->save(array("status"=>$cc4));
				if($kajww==$coajww-1){
					M("jihua_ajssc_ww")->where("id = '{$resajww['id']}'")->save(array("status"=>$cc4,"is_do"=>1));
					$start4 = $neajwww[$bs]+1;
					$mid4 = $neajwww[$bs]+2;
					$end4 = $neajwww[$bs]+3;
					$dat14['issue'] = $start4."-".$end4;
					$nyi4 = explode("-",$dat14['issue']);
					$numbers4 = range(0, 9);
					//shuffle 将数组顺序随即打乱
					shuffle($numbers4);
					//array_slice 取该数组中的某一段
					$num4 = 5;
					$result4 = array_slice($numbers4, 0, $num4);
					$dat14['he'] = implode(",", $result4);
					$dat14['status'] = "等待开奖";
					M("jihua_ajssc_ww")->add($dat14);
				}
			}
		}
	}
    //数据解析
    static function ren_gong($arr,$lotteryclass_id,$issue){
        if(empty($arr)||empty($lotteryclass_id)||empty($issue)){
            return false;
        }
        $rarr = array();
        foreach($arr as $v){
            if($v['lotteryclass_id']==$lotteryclass_id&&$v['issue']==$issue){
                $v['issue'] = trim($v['issue']);
                $rarr[] = $v;
            }
        }
        return $rarr;
    }
	public function get_url($na){
		$ch1 = curl_init(); 
		curl_setopt ($ch1, CURLOPT_URL,$na);
		curl_setopt ($ch1, CURLOPT_RETURNTRANSFER, 1); 
		$file_contents1 = curl_exec($ch1);
		curl_close($ch1);
		return $file_contents1;
	}
    //一秒执行一次添加下期
    public function add_xia(){
        $lottery_clas_id = array(
            'gd11x5' =>'22',
            'jx11x5' =>'25',
            'sd11x5' =>'24',
            'sh11x5' =>'23',
            'ahk3' =>'2',
            'bjk3' =>'5',
            'gsk3' =>'10',
            'gxk3' =>'3',
            'gzk3' =>'12',
            'hebk3' =>'9',
            'hubk3' =>'4',
            'jlk3' =>'13',
            'jsk3' =>'1',
            'shk3' =>'11',
            'cqssc' =>'15',
            'tjssc' =>'18',
            'xjssc' =>'17',
            'bjkl8' =>'20',
            'bjpk10' =>'21',
            'ffc2' =>'19',
            'fc3d' =>'26',
            'pl3' =>'27',
        );
        $lottery_clas_id1 = array(
            '22' =>'gd11x5',
            '25' =>'jx11x5',
            '24' =>'sd11x5',
            '23' =>'sh11x5',
            '2' =>'ahk3',
            '5' =>'bjk3',
            '10' =>'gsk3',
            '3' =>'gxk3',
            '12' =>'gzk3',
            '9' =>'hebk3',
            '4' =>'hubk3',
            '13' =>'jlk3',
            '1' =>'jsk3',
            '11' =>'shk3',
            '15' =>'cqssc',
            '18' =>'tjssc',
            '17' =>'xjssc',
            '20' =>'bjkl8',
            '21' =>'bjpk10',
            '19' =>'ffc2',
            '26' =>'fc3d',
            '27' =>'pl3',
        );

        for($i=0;$i<10;$i++) {
            $lottery_class = M("lottery_class")->where("id not in (26,27)")->select();
            $zou_date = array();
            foreach ($lottery_class as $v) {
                $id = $v['id'];
                $xopentime = strtotime($v['opentime']) + $v['jian_time'] * 60;
                $jia = 0;
                $issue = trim($v['issue']) + 1;
                if ($id == 1) {
                    $s1 = trim(date("Y-m-d") . " " . $v['stime']);//彩票的开始时间
                    $s2 = trim(date("Y-m-d") . " " . $v['etime']);//彩票的结束时间
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $v = strtotime(date("Y-m-d") . " " . "08:30:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 2) {
                    $s1 = date("Y-m-d") . " " . $v['stime'];
                    $s2 = date("Y-m-d") . " " . $v['etime'];
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "08:50:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 3) {
                    $s1 = trim(date("Y-m-d") . " " . $v['stime']);//彩票的开始时间
                    $s2 = trim(date("Y-m-d") . " " . $v['etime']);//彩票的结束时间
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "09:28:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 4) {
                    $s1 = date("Y-m-d") . " " . $v['stime'];
                    $s2 = date("Y-m-d") . " " . $v['etime'];
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "09:00:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 5) {
                    $s1 = date("Y-m-d") . " " . $v['stime'];
                    $s2 = date("Y-m-d") . " " . $v['etime'];
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "09:00:00");
                        }
                    }
                } elseif ($id == 9) {
                    $s1 = trim(date("Y-m-d") . " " . $v['stime']);//彩票的开始时间
                    $s2 = trim(date("Y-m-d") . " " . $v['etime']);//彩票的结束时间
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "08:30:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 10) {
                    $s1 = trim(date("Y-m-d") . " " . $v['stime']);//彩票的开始时间
                    $s2 = trim(date("Y-m-d") . " " . $v['etime']);//彩票的结束时间
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "09:50:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 11) {
                    $s1 = trim(date("Y-m-d") . " " . $v['stime']);//彩票的开始时间
                    $s2 = trim(date("Y-m-d") . " " . $v['etime']);//彩票的结束时间
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "08:40:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 12) {
                    $s1 = trim(date("Y-m-d") . " " . $v['stime']);//彩票的开始时间
                    $s2 = trim(date("Y-m-d") . " " . $v['etime']);//彩票的结束时间
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "09:00:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 13) {
                    $s1 = trim(date("Y-m-d") . " " . $v['stime']);//彩票的开始时间
                    $s2 = trim(date("Y-m-d") . " " . $v['etime']);//彩票的结束时间
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "08:20:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 15) {
                    $s1 = date("Y-m-d") . " " . $v['stime']; //当天开始的时间
                    $ss = date("Y-m-d") . " " . $v['etime'];//结束的时间

                    if ($ss < time()) {  //如果当前时间大于结束时间
                        $s2 = date("Y-m-d", strtotime("+1 day")) . " " . $v['etime'];
                    } else {
                        $s2 = date("Y-m-d") . " " . $v['etime'];
                    }

                    if (strtotime($s1) > time()) {  //如果当前时间大于结束时间
                        $s1 = date("Y-m-d", strtotime("-1day")) . " " . $v['stime'];
                    } else {
                        $s1 = date("Y-m-d") . " " . $v['stime'];
                    }
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "10:00:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 17) {
                    $s1 = date("Y-m-d") . " " . trim($v['stime']);

                    if (strtotime($v['etime']) < strtotime($v['stime'])) {
                        $s2 = date("Y-m-d", strtotime("+1 day")) . " " . $v['etime'];
                    } else {
                        $s2 = date("Y-m-d") . " " . trim($v['etime']);
                    }
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "10:00:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 18) {
                    $s1 = trim(date("Y-m-d") . " " . $v['stime']);//彩票的开始时间
                    $s2 = trim(date("Y-m-d") . " " . $v['etime']);//彩票的结束时间
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "09:00:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 20) {
                    $s1 = trim(date("Y-m-d") . " " . $v['stime']);//彩票的开始时间
                    $s2 = trim(date("Y-m-d") . " " . $v['etime']);//彩票的结束时间
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "09:05:00");
                        }
                    }
                } elseif ($id == 21) {
                    $s1 = trim(date("Y-m-d") . " " . $v['stime']);//彩票的开始时间
                    $s2 = trim(date("Y-m-d") . " " . $v['etime']);//彩票的结束时间
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "09:00:00");
                        }
                    }
                } elseif ($id == 22) {
                    $s1 = trim(date("Y-m-d") . " " . $v['stime']);//彩票的开始时间
                    $s2 = trim(date("Y-m-d") . " " . $v['etime']);//彩票的结束时间
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "09:10:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 23) {
                    $s1 = trim(date("Y-m-d") . " " . $v['stime']);//彩票的开始时间
                    $s2 = trim(date("Y-m-d") . " " . $v['etime']);//彩票的结束时间
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "09:05:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 24) {
                    $s1 = trim(date("Y-m-d") . " " . $v['stime']);//彩票的开始时间
                    $s2 = trim(date("Y-m-d") . " " . $v['etime']);//彩票的结束时间
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "08:35:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                } elseif ($id == 25) {
                    $s1 = trim(date("Y-m-d") . " " . $v['stime']);//彩票的开始时间
                    $s2 = trim(date("Y-m-d") . " " . $v['etime']);//彩票的结束时间
                    if (strtotime($s1) <= time() && strtotime($s2) >= time() && $xopentime < strtotime($s2)) {
                        $jia = 1;
                        if ($xopentime <= $s1) {
                            $xopentime = strtotime(date("Y-m-d") . " " . "09:10:00");
                            $issue = date('Ymd') . '001';
                        }
                    }
                }
                if (($v['id'] == 19 || $jia != 0) && $issue != '' && $xopentime <= time()) {
                    $zou_date[] = array(
                        'issue' => $issue,
                        'opencode' => '',
                        'opentime' => date('Y-m-d H:i:s',$xopentime),
                        'code' => $lottery_clas_id1[$v['id']],
                    );
                }
            }
            $date = $zou_date;
            if (!empty($date)) {
                $issue = '';
                $opencode = '';
                $opentime = '';
                $opentimestamp = '';
                foreach ($date as $v) {
                    $opentimestamp1 = strtotime($v['opentime']);
                    $issue .= "  when id={$lottery_clas_id[$v['code']]} then '{$v['issue']}' ";
                    $opencode .= "  when id={$lottery_clas_id[$v['code']]} then '{$v['opencode']}' ";
                    $opentime .= "  when id={$lottery_clas_id[$v['code']]} then '{$v['opentime']}' ";
                    $opentimestamp .= "  when id={$lottery_clas_id[$v['code']]} then '{$opentimestamp1}' ";
                }
                $sql = "update " . C("DB_PREFIX") . "lottery_class set issue = case {$issue} else issue end,opencode = case {$opencode} else opencode end,opentime = case {$opentime} else opentime end,opentimestamp = case {$opentimestamp} else opentimestamp end ";
                M()->execute($sql);
                M("zoushitu")->addAll($date);
            }
            sleep(1);
        }
    }
	//1分钟1次
	public function jsons(){
//        for($i=0;$i<=55;$i=$i+5) {
            $jieguo = M("zoushitu")->where("1=1")->order("id desc")->limit(200)->select();
            $jg = array();
            foreach ($jieguo as $v) {
                $v['issue'] = trim($v['issue']);
                $v['opencode'] = trim($v['opencode']);
                $v['opentime'] = trim($v['opentime']);
                $v['code'] = trim($v['code']);
                if (!isset($jg[$v['code']])) {
                    $jg[$v['code']] = $v;
                }
            }
            //江苏快3
            $url1 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=jsk3&format=json&rows=2";
            $data1 = $this->get_url($url1);
            file_put_contents('./public/json/jsk3.json', $data1);
            //安徽快3
            $url2 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=ahk3&format=json&rows=2";
            $data2 = $this->get_url($url2);
            file_put_contents('./public/json/ahk3.json', $data2);
            //广西快3
            $url3 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=gxk3&format=json&rows=2";
            $data3 = $this->get_url($url3);
            file_put_contents('./public/json/gxk3.json', $data3);
            //湖北快3
            $url4 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=hubk3&format=json&rows=2";
            $data4 = $this->get_url($url4);
            file_put_contents('./public/json/hubk3.json', $data4);
            //北京快3
            $url5 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=bjk3&format=json&rows=2";
            $data5 = $this->get_url($url5);
            file_put_contents('./public/json/bjk3.json', $data5);
            //河北快3
            $url6 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=hebk3&format=json&rows=2";
            $data6 = $this->get_url($url6);
            file_put_contents('./public/json/hebk3.json', $data6);
            //甘肃快3
            $url7 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=gsk3&format=json&rows=2";
            $data7 = $this->get_url($url7);
            file_put_contents('./public/json/gsk3.json', $data7);
            //上海快3
            $url8 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=shk3&format=json&rows=2";
            $data8 = $this->get_url($url8);
            file_put_contents('./public/json/shk3.json', $data8);
            //贵州快3
            $url9 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=gzk3&format=json&rows=2";
            $data9 = $this->get_url($url9);
            file_put_contents('./public/json/gzk3.json', $data9);
            //吉林快3
            $url10 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=jlk3&format=json&rows=2";
            $data10 = $this->get_url($url10);
            file_put_contents('./public/json/jlk3.json', $data10);
            //重庆时时彩
            $url11 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=cqssc&format=json&rows=2";
            $data11 = $this->get_url($url11);
            file_put_contents('./public/json/cqssc.json', $data11);
            //新疆时时彩
            $url12 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=xjssc&format=json&rows=2";
            $data12 = $this->get_url($url12);
            file_put_contents('./public/json/xjssc.json', $data12);
            //天津时时彩
            $url13 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=tjssc&format=json&rows=2";
            $data13 = $this->get_url($url13);
            file_put_contents('./public/json/tjssc.json', $data13);
            //埃及二分彩
            $url14 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=ffc2&format=json&rows=2";
            $data14 = $this->get_url($url14);
            file_put_contents('./public/json/ffc2.json', $data14);
            //北京kl8
            $url15 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=bjkl8&format=json&rows=2";
            $data15 = $this->get_url($url15);
            file_put_contents('./public/json/bjkl8.json', $data15);
            //北京pk10
            $url16 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=bjpk10&format=json&rows=2";
            $data16 = $this->get_url($url16);
            file_put_contents('./public/json/bjpk10.json', $data16);
            //广东11选5
            $url17 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=gd11x5&format=json&rows=2";
            $data17 = $this->get_url($url17);
            file_put_contents('./public/json/gd11x5.json', $data17);
            //上海11
            $url18 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=sh11x5&format=json&rows=2";
            $data18 = $this->get_url($url18);
            file_put_contents('./public/json/sh11x5.json', $data18);
            //山东11
            $url19 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=sd11x5&format=json&rows=2";
            $data19 = $this->get_url($url19);
            file_put_contents('./public/json/sd11x5.json', $data19);
            //江西11
            $url20 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=jx11x5&format=json&rows=2";
            $data20 = $this->get_url($url20);
            file_put_contents('./public/json/jx11x5.json', $data20);
            $date = array();
            $del_where = array();
            for ($i = 1; $i <= 20; $i++) {
                $data = "data" . $i;
                $data1 = json_decode($$data);
                if (!empty($data1->data[0]->expect)) {
                    if($data1->data[0]->expect == $jg[$data1->code]['issue']&&empty($jg[$data1->code]['opencode'])){
                        $del_where[] = " (issue='{$jg[$data1->code]['issue']}' and code = '{$data1->code}') ";
                        $date[] = array(
                            'issue' => trim($data1->data[0]->expect),
                            'opencode' => trim($data1->data[0]->opencode),
                            'opentime' => trim($data1->data[0]->opentime),
                            'code' => trim($data1->code),
                        );
                    }
                }
            }
            $lottery_clas_id = array(
                'gd11x5' =>'22',
                'jx11x5' =>'25',
                'sd11x5' =>'24',
                'sh11x5' =>'23',
                'ahk3' =>'2',
                'bjk3' =>'5',
                'gsk3' =>'10',
                'gxk3' =>'3',
                'gzk3' =>'12',
                'hebk3' =>'9',
                'hubk3' =>'4',
                'jlk3' =>'13',
                'jsk3' =>'1',
                'shk3' =>'11',
                'cqssc' =>'15',
                'tjssc' =>'18',
                'xjssc' =>'17',
                'bjkl8' =>'20',
                'bjpk10' =>'21',
                'ffc2' =>'19',
                'fc3d' =>'26',
                'pl3' =>'27',
            );
            if (!empty($date)) {
                $issue = '';
                $opencode = '';
                $opentime = '';
                $opentimestamp = '';
                foreach($date as $v){
                    $opentimestamp1 = strtotime($v['opentime']);
                    $issue .= "  when id={$lottery_clas_id[$v['code']]} then '{$v['issue']}' ";
                    $opencode .= "  when id={$lottery_clas_id[$v['code']]} then '{$v['opencode']}' ";
                    $opentime .= "  when id={$lottery_clas_id[$v['code']]} then '{$v['opentime']}' ";
                    $opentimestamp .= "  when id={$lottery_clas_id[$v['code']]} then '{$opentimestamp1}' ";
                }
                if(!empty($del_where)){
                    $del_where = implode(" or ",$del_where);
                    M("zoushitu")->where($del_where)->delete();
                }
                $sql = "update " . C("DB_PREFIX") . "lottery_class set issue = case {$issue} else issue end,opencode = case {$opencode} else opencode end,opentime = case {$opentime} else opentime end,opentimestamp = case {$opentimestamp} else opentimestamp end ";
                M()->execute($sql);
                M("zoushitu")->addAll($date);
            }
//            sleep(5);
//        }
	}
	//福彩3d (每天21：21分和23分执行一次)
	public function fc3d(){
        $jieguo = M("zoushitu")->where("code in ('fc3d','pl3')")->order("id desc")->limit(20)->select();
        $jg = array();
        foreach($jieguo as $v){
            $v['issue'] = trim($v['issue']);
            $v['opencode'] = trim($v['opencode']);
            $v['opentime'] = trim($v['opentime']);
            $v['code'] = trim($v['code']);
            if(!isset($jg[$v['code']])){
                $jg[$v['code']] = $v;
            }
        }
		//福彩3d
		$url1 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=fc3d&format=json&rows=2";
        $data1 = $this->get_url($url1);
		file_put_contents('./public/json/fc3d.json',$data1);
		//排列3
		$url2 = "http://a.apiplus.net/newly.do?token=7684e585c2f14db0&code=pl3&format=json&rows=2";
        $data2 = $this->get_url($url2);
		file_put_contents('./public/json/pl3.json',$data2);
        $date = array();
        for($i=1;$i<=2;$i++) {
            $data = "data".$i;
            $data1 = json_decode($$data);
            if(!empty($data1->data[0]->expect)) {
                if (empty($jg[$data1->code]['issue'])|| $data1->data[0]->expect > $jg[$data1->code]['issue']) {
                    $date[] = array(
                        'issue' => trim($data1->data[0]->expect),
                        'opencode' => trim($data1->data[0]->opencode),
                        'opentime' => trim($data1->data[0]->opentime),
                        'code' => trim($data1->code),
                    );
                }
            }
        }
        $lottery_clas_id = array(
            'gd11x5' =>'22',
            'jx11x5' =>'25',
            'sd11x5' =>'24',
            'sh11x5' =>'23',
            'ahk3' =>'2',
            'bjk3' =>'5',
            'gsk3' =>'10',
            'gxk3' =>'3',
            'gzk3' =>'12',
            'hebk3' =>'9',
            'hubk3' =>'4',
            'jlk3' =>'13',
            'jsk3' =>'1',
            'shk3' =>'11',
            'cqssc' =>'15',
            'tjssc' =>'18',
            'xjssc' =>'17',
            'bjkl8' =>'20',
            'bjpk10' =>'21',
            'ffc2' =>'19',
            'fc3d' =>'26',
            'pl3' =>'27',
        );
        if(!empty($date)){
            $issue = '';
            $opencode = '';
            $opentime = '';
            $opentimestamp = '';
            foreach($date as $v){
                $opentimestamp1 = strtotime($v['opentime']);
                $issue .= "  when id={$lottery_clas_id[$v['code']]} then '{$v['issue']}' ";
                $opencode .= "  when id={$lottery_clas_id[$v['code']]} then '{$v['opencode']}' ";
                $opentime .= "  when id={$lottery_clas_id[$v['code']]} then '{$v['opentime']}' ";
                $opentimestamp .= "  when id={$lottery_clas_id[$v['code']]} then '{$opentimestamp1}' ";
            }
            $sql = "update " . C("DB_PREFIX") . "lottery_class set issue = case {$issue} else issue end,opencode = case {$opencode} else opencode end,opentime = case {$opentime} else opentime end,opentimestamp = case {$opentimestamp} else opentimestamp end ";
            M()->execute($sql);
            M("zoushitu")->addAll($date);
        }
	}
    /*
     * 测试计划热舞
     */
    public function ceshi(){
        $fp = fopen("./test.txt", "a+");
        fwrite($fp, date("Y-m-d H:i:s") . " 成功成功了！\n");
        fclose($fp);
    }
}
?>